/* ============================================================
   DR4K Admin Panel — Minimalist Dark Theme
   Inspired by Pinterest design philosophy
   ============================================================ */

/* --- 1. CSS Variables --- */
:root {
    --bg-primary: #0F0F14;
    --bg-secondary: #1A1A22;
    --bg-elevated: #222230;
    --bg-hover: #2A2A38;
    --bg-input: #1A1A22;
    --bg-input-focus: #222230;
    --bg-accent: #222230;

    --text-body: #E0E0E6;
    --text-heading: #F1F1F4;
    --text-muted: #9CA3AF;
    --text-placeholder: #6B7280;

    --color-accent: #818CF8;
    --color-accent-hover: #6366F1;
    --color-accent-subtle: rgba(129, 140, 248, 0.10);
    --color-success: #34D399;
    --color-error: #F87171;
    --color-warning: #FBBF24;
    --color-info: #818CF8;
    --color-primary: #818CF8;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.10);
    --border-focus: rgba(129, 140, 248, 0.40);

    --radius-sm: 8px;
    --radius-card: 14px;
    --radius-input: 10px;
    --radius-badge: 20px;
    --radius-pill: 999px;

    --sidebar-width: 240px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-glow: 0 0 20px rgba(129, 140, 248, 0.08);

    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}


/* --- 2. Reset + Base Styles --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-body);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent-hover);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: 0.95rem; }
h6 { font-size: 0.85rem; }

p { margin-bottom: 0.75rem; }

img { max-width: 100%; height: auto; }

code {
    font-family: var(--font-mono);
    background: var(--bg-elevated);
    padding: 0.15em 0.45em;
    border-radius: 6px;
    font-size: 0.88em;
    color: var(--color-accent);
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

::selection {
    background: rgba(129, 140, 248, 0.25);
    color: var(--text-heading);
}


/* --- 3. Layout: App, Sidebar, Main --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    margin: 0;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
    font-weight: 400;
}


/* --- 4. Sidebar --- */
.sidebar-logo {
    padding: 1.5rem 1.25rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-logo h1 {
    font-size: 1.6rem;
    letter-spacing: 3px;
    margin: 0;
    color: var(--text-heading);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
}

.sidebar-subtitle {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.6rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border-left: none;
    border-radius: var(--radius-sm);
    text-decoration: none;
    margin-bottom: 2px;
}

.nav-link:hover {
    color: var(--text-body);
    background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
    color: var(--color-accent);
    background: var(--color-accent-subtle);
    border-left-color: transparent;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    padding: 1rem 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.user-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-link {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
    white-space: nowrap;
}

.logout-link:hover {
    color: var(--color-error);
}


/* --- 5. Cards --- */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal), border-color var(--transition-normal), transform var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-icon {
    align-self: flex-end;
    opacity: 0.25;
    margin-top: -2.5rem;
}

.template-card {
    position: relative;
    overflow: hidden;
}

.template-card .card-thumbnail {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    width: calc(100% + 3rem);
    background: var(--bg-primary);
}

.template-card .card-type-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}


/* --- 6. Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-family);
    color: var(--text-body);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-input);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    background: var(--bg-hover);
    color: var(--text-heading);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: #ffffff;
    box-shadow: var(--shadow-glow);
}

.btn-success {
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.20);
    color: var(--color-success);
}

.btn-success:hover {
    background: rgba(52, 211, 153, 0.20);
    border-color: rgba(52, 211, 153, 0.30);
    color: var(--color-success);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.20);
    color: var(--color-error);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.20);
    border-color: rgba(248, 113, 113, 0.30);
    color: var(--color-error);
}

.btn-warning {
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.20);
    color: var(--color-warning);
}

.btn-warning:hover {
    background: rgba(251, 191, 36, 0.20);
    border-color: rgba(251, 191, 36, 0.30);
    color: var(--color-warning);
}

.btn-sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
}

.btn-lg {
    padding: 0.8rem 1.6rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.5rem;
    line-height: 1;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}


/* --- 7. Forms --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="url"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-family: var(--font-family);
    color: var(--text-body);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-input);
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-placeholder);
}

input:read-only,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: rgba(15, 15, 20, 0.5);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.5rem;
}

.form-group {
    margin-bottom: 1.15rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-label .required {
    color: var(--color-error);
    margin-left: 0.15rem;
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-placeholder);
}

.form-error {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--color-error);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* File Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-card);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: transparent;
    position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--color-accent);
    background: var(--color-accent-subtle);
}

.upload-zone.has-file {
    border-color: var(--color-success);
    background: rgba(52, 211, 153, 0.06);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-zone .upload-icon {
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.upload-zone .upload-icon svg {
    width: 36px;
    height: 36px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

.upload-zone .upload-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.upload-zone .upload-text strong {
    color: var(--color-accent);
}

.upload-zone .upload-hint {
    font-size: 0.78rem;
    color: var(--text-placeholder);
    margin-top: 0.35rem;
}

.upload-zone .upload-filename {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-success);
    font-weight: 500;
}

/* Image preview for photo upload */
.image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-input);
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
}


/* --- 8. Tables --- */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--bg-elevated);
}

th {
    padding: 0.85rem 1.15rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* No alternating row colors -- clean flat design */

tbody tr:last-child td {
    border-bottom: none;
}

td.actions {
    white-space: nowrap;
}

.table-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}


/* --- 9. Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.badge-success {
    background: rgba(52, 211, 153, 0.12);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(251, 191, 36, 0.12);
    color: var(--color-warning);
}

.badge-danger,
.badge-error {
    background: rgba(248, 113, 113, 0.12);
    color: var(--color-error);
}

.badge-info {
    background: rgba(129, 140, 248, 0.12);
    color: var(--color-info);
}

.badge-neutral,
.badge-secondary {
    background: rgba(156, 163, 175, 0.12);
    color: var(--text-muted);
}


/* --- 10. Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.60);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.15s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 18px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.modal-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-header button:hover {
    color: var(--text-heading);
}

.modal-body {
    padding: 1.5rem;
    font-size: 0.92rem;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}


/* --- 11. Tabs (Pill Style) --- */
.tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-input);
    padding: 4px;
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.55rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
    border-radius: calc(var(--radius-input) - 2px);
}

.tab:hover {
    color: var(--text-body);
    background: rgba(255, 255, 255, 0.04);
}

.tab-active,
.tab.active {
    color: var(--text-heading);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}

/* Remove the underline indicator (pill style, no underline) */
.tab-active::after,
.tab.active::after {
    content: none;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}


/* --- 12. Alerts + Toasts --- */
.alert {
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius-input);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: rgba(52, 211, 153, 0.08);
    border-color: var(--color-success);
    color: var(--color-success);
}

.alert-error {
    background: rgba(248, 113, 113, 0.08);
    border-color: var(--color-error);
    color: var(--color-error);
}

.alert-warning {
    background: rgba(251, 191, 36, 0.08);
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.alert-info {
    background: rgba(129, 140, 248, 0.08);
    border-color: var(--color-info);
    color: var(--color-info);
}

.alert .alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.alert .alert-close:hover {
    opacity: 1;
}

/* Toast container */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1.15rem;
    border-radius: var(--radius-input);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    pointer-events: auto;
    max-width: 380px;
}

.toast-success {
    background: rgba(52, 211, 153, 0.18);
    border: 1px solid rgba(52, 211, 153, 0.25);
    color: var(--color-success);
}

.toast-error {
    background: rgba(248, 113, 113, 0.18);
    border: 1px solid rgba(248, 113, 113, 0.25);
    color: var(--color-error);
}

.toast-warning {
    background: rgba(251, 191, 36, 0.18);
    border: 1px solid rgba(251, 191, 36, 0.25);
    color: var(--color-warning);
}

.toast-info {
    background: rgba(129, 140, 248, 0.18);
    border: 1px solid rgba(129, 140, 248, 0.25);
    color: var(--color-info);
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}


/* --- 13. Generate Page Layout --- */
.generate-layout {
    display: grid;
    grid-template-columns: 45% 55%;
    gap: 1.5rem;
    align-items: start;
}

.generate-form-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1.5rem;
}

.preview-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    position: sticky;
    top: 1.5rem;
}

.preview-canvas-wrapper {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-input);
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 1rem;
}

.preview-canvas-wrapper img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
}

.preview-placeholder {
    text-align: center;
    color: var(--text-placeholder);
    padding: 3rem 1rem;
}

.preview-placeholder svg {
    width: 48px;
    height: 48px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Auto-generated fields (read-only group) */
.auto-field-group {
    background: rgba(129, 140, 248, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1rem;
    margin-top: 1rem;
}

.auto-field-group .group-label {
    font-size: 0.78rem;
    color: var(--text-placeholder);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}


/* --- 14. Recent / User Cards --- */
.user-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.doc-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    overflow: hidden;
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.doc-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.doc-card .doc-preview {
    height: 160px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.doc-card .doc-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doc-card .doc-info {
    padding: 1rem;
}

.doc-card .doc-info h4 {
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.doc-card .doc-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.action-buttons {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}


/* --- 15. Login Page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 1rem;
}

.login-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 2rem;
    letter-spacing: 4px;
    color: var(--text-heading);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
    margin-bottom: 0.25rem;
}

.login-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form .btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.login-error {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.20);
    color: var(--color-error);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-input);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    text-align: center;
}


/* --- 16. Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0.25rem 0.65rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.pagination a:hover {
    background: var(--bg-elevated);
    color: var(--text-heading);
}

.pagination .active,
.pagination .current {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
    font-weight: 600;
}

.pagination .disabled,
.pagination .ellipsis {
    opacity: 0.35;
    pointer-events: none;
}


/* --- 17. Search Bar --- */
.search-bar {
    position: relative;
    max-width: 360px;
}

.search-bar input {
    padding-left: 2.5rem;
}

.search-bar .search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-placeholder);
    pointer-events: none;
}

.search-bar .search-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Filter bar (search + filters combo) */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.filter-bar select {
    width: auto;
    min-width: 150px;
}


/* --- 18. Loading Spinner --- */
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-light);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 42px;
    height: 42px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 20, 0.80);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 50;
    border-radius: inherit;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.loading-overlay .loading-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}


/* --- 19. Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.10);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.10) transparent;
}


/* --- 20. Utility Classes --- */
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }
.text-info { color: var(--color-info); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    margin-bottom: 1rem;
    opacity: 0.35;
}

.empty-state h3 {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.88rem;
    max-width: 360px;
    margin: 0 auto;
    color: var(--text-placeholder);
}


/* --- 21. Metric Grid & Revenue Grid (Dashboard / Payments) --- */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.metric-card .metric-label {
    font-size: 0.75rem;
    color: var(--text-placeholder);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.metric-card .metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1;
}

.metric-card .metric-value.text-warning { color: var(--color-warning); }
.metric-card .metric-value.text-success { color: var(--color-success); }
.metric-card .metric-value.text-info { color: var(--color-info); }

.metric-card .metric-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.metric-card .metric-sub .positive { color: var(--color-success); }
.metric-card .metric-sub .info-tag { color: var(--color-info); }

.metric-row {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.revenue-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.revenue-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1rem 1.25rem;
    text-align: center;
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.revenue-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.revenue-card .rev-label {
    font-size: 0.72rem;
    color: var(--text-placeholder);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.revenue-card .rev-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-success);
}

.bottom-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-lg);
}


/* --- 21b. Worker Status Card (Dashboard) --- */
.worker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.worker-actions {
    display: flex;
    gap: 0.5rem;
}

.worker-cost {
    display: none;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.worker-cost span + span {
    margin-left: 0.5rem;
}

.worker-progress {
    display: none;
    margin-top: 0.75rem;
}

.worker-progress .progress-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.worker-progress .progress-track {
    background: var(--bg-secondary);
    border-radius: 4px;
    height: 6px;
    margin-top: 0.3rem;
    overflow: hidden;
}

.worker-progress .progress-fill {
    height: 100%;
    background: var(--color-primary);
    width: 0%;
    transition: width 0.3s;
}

.worker-progress .progress-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* --- 21c. Tag List (Sidebar stat cards) --- */
.tag-list {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tag-item .tag-count {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-heading);
}

/* --- 21d. Action Stack (vertical button list) --- */
.action-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-stack .btn {
    width: 100%;
    text-align: center;
}

/* --- 21e. Metric value font-size variant --- */
.metric-value-sm {
    font-size: 1.1rem;
}

/* Table badge small */
.badge-sm {
    font-size: 0.65rem;
}

/* Nowrap cell */
.cell-nowrap {
    white-space: nowrap;
    font-size: 0.82rem;
}

/* Sidebar card total count */
.card-header .header-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
}


/* --- 22. Filter Tabs (Pill Style) --- */
.filter-tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-input);
    padding: 4px;
    margin-bottom: var(--space-lg);
}

.filter-tabs a {
    padding: 0.55rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    position: relative;
    transition: all var(--transition-fast);
    border-radius: calc(var(--radius-input) - 2px);
}

.filter-tabs a:hover {
    color: var(--text-body);
    background: rgba(255, 255, 255, 0.04);
}

.filter-tabs a.active {
    color: var(--text-heading);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}

/* Remove underline indicator for pill style */
.filter-tabs a.active::after {
    content: none;
}

.filter-tabs .tab-count {
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 0.3rem;
    opacity: 0.6;
}


/* --- 23. Responsive --- */
@media (max-width: 1366px) {
    .main-content {
        padding: 1.5rem 2rem;
    }

    .generate-layout {
        grid-template-columns: 48% 52%;
        gap: 1.25rem;
    }

    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
        min-width: 200px;
    }

    .main-content {
        margin-left: 200px;
    }

    .generate-layout {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        position: static;
    }

    .metric-grid,
    .revenue-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        z-index: 200;
        width: var(--sidebar-width);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row.three-col {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar select {
        width: 100%;
    }

    .search-bar {
        max-width: 100%;
    }

    .stat-card .stat-value {
        font-size: 1.6rem;
    }

    .metric-grid,
    .revenue-grid {
        grid-template-columns: 1fr;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
}

/* Mobile menu toggle (only visible on small screens) */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 250;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    color: var(--text-body);
    cursor: pointer;
}

.mobile-menu-toggle svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}


/* --- 24. Recent Detail Page --- */
.render-detail-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* doc-card last meta row spacing */
.doc-card .doc-meta:last-child {
    margin-bottom: 0;
}

/* Header actions row on recent page */
.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 1024px) {
    .render-detail-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .header-actions select {
        width: 100%;
    }

    .doc-card-grid {
        grid-template-columns: 1fr !important;
    }

    .btn-group {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .metric-grid,
    .revenue-grid {
        grid-template-columns: 1fr;
    }
}
