/* =========================================================
   AGENTFLOW - MODERN LIGHT DESIGN SYSTEM
   Clean, Professional, High-Contrast Executive Theme
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Light Theme Palette */
    --bg-app: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-subtle: #f1f5f9;
    --bg-hover: #e2e8f0;

    --border-light: #e2e8f0;
    --border-subtle: #edf2f7;
    --border-focus: #18551c;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    /* Satguru Corporate Brand Identity (Extracted from Official Logo) */
    --brand-green: #18551c;
    --brand-green-hover: #124215;
    --brand-green-light: #f1f7f1;
    --brand-green-border: #c6d9c8;

    --brand-orange: #ff5a08;
    --brand-orange-hover: #e04b00;
    --brand-orange-light: #fff4ed;
    --brand-orange-border: #fed7aa;

    /* Primary Accent (Satguru Green) */
    --primary: #18551c;
    --primary-hover: #124215;
    --primary-light: #f1f7f1;
    --primary-border: #c6d9c8;

    /* Secondary Accent (Satguru Orange) */
    --accent: #ff5a08;
    --accent-hover: #e04b00;
    --accent-light: #fff4ed;
    --accent-border: #fed7aa;

    /* Semantic Status Colors */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --success-text: #065f46;

    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --warning-text: #92400e;

    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #991b1b;

    --info: #0ea5e9;
    --info-bg: #f0f9ff;
    --info-border: #bae6fd;
    --info-text: #075985;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Shell Layout */
.shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    padding: 24px 16px;
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px 8px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 20px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #18551c, #ff5a08);
    color: white;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(24, 85, 28, 0.25);
}

.brand-logo-img {
    height: 42px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    display: block;
}

.brand-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    opacity: 0.75;
}

.nav-link:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-link.active svg {
    color: var(--primary);
    opacity: 1;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.db-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 8px 10px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.db-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Main Content Area */
.main {
    margin-left: 260px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    padding: 16px 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    flex-direction: column;
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.4px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #18551c, #2b7830);
    color: white;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-meta {
    line-height: 1.2;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
}

/* Page Container */
.content-wrapper {
    padding: 28px 36px 60px;
    flex: 1;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px 30px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.hero h2 {
    margin: 4px 0 6px;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.hero p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Metric Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
}

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

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.metric-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.metric-icon.indigo { background: var(--primary-light); color: var(--primary); }
.metric-icon.green  { background: var(--success-bg); color: var(--success); }
.metric-icon.amber  { background: var(--warning-bg); color: var(--warning); }
.metric-icon.rose   { background: var(--danger-bg); color: var(--danger); }
.metric-icon.sky    { background: var(--info-bg); color: var(--info); }

.metric-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -1px;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* Panels */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.panel-head {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}

.panel-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-head p {
    margin: 3px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

.panel-body {
    padding: 24px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13.5px;
    color: var(--text-primary);
    vertical-align: middle;
}

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

tr:hover td {
    background-color: #f8fafc;
}

/* Code & Badges */
.code {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    background: #f1f5f9;
    color: #334155;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    text-transform: capitalize;
}

.pill.verified, .pill.sent, .pill.ready, .pill.active {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.pill.pending, .pill.unverified, .pill.new {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
}

.pill.failed, .pill.review, .pill.disabled {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.pill.purple, .pill.admin, .pill.all {
    background: #f5f3ff;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
}

.pill.blue, .pill.own {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.pill.custom {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    line-height: 1.4;
}

.btn:hover {
    background: var(--bg-subtle);
    border-color: #cbd5e1;
}

.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(24, 85, 28, 0.3);
}

.btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn.accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(255, 90, 8, 0.3);
}

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

.btn.danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.btn.danger:hover {
    background: #fee2e2;
}

.btn.tiny {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Toolbar & Filters */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 2px 12px;
    flex: 1;
    max-width: 480px;
    box-shadow: var(--shadow-sm);
}

.search-box input {
    border: none;
    outline: none;
    padding: 9px 8px;
    font-size: 13.5px;
    width: 100%;
    color: var(--text-primary);
    background: transparent;
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-subtle);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.filter-pill {
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.filter-pill:hover {
    color: var(--text-primary);
}

.filter-pill.active {
    background: var(--bg-surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    font-family: var(--font-sans);
    font-size: 13.5px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Upload Page Styles */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-xl);
    padding: 36px 24px;
    text-align: center;
    background: #fafbfc;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    position: relative;
}

.upload-dropzone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    font-size: 24px;
}

.preview-container {
    max-width: 100%;
    max-height: 180px;
    margin-top: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    overflow: hidden;
    display: none;
}

.preview-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Review & Detail Section */
.review-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
    align-items: start;
}

.card-preview-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 90px;
}

.card-img-wrap {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: #f1f5f9;
    margin-bottom: 16px;
}

.card-img-wrap img {
    width: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.card-img-wrap:hover img {
    transform: scale(1.02);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.detail-item {
    background: var(--bg-subtle);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.detail-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

/* Alerts & Flash */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert.success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.alert.error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    place-items: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active {
    display: grid;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    width: min(540px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { width: 80px; padding: 20px 8px; align-items: center; }
    .brand-title, .brand-subtitle, .nav-text, .db-badge, .sidebar-footer { display: none; }
    .main { margin-left: 80px; }
    .review-layout { grid-template-columns: 1fr; }
    .card-preview-box { position: static; }
    .topbar { padding: 14px 20px; }
    .content-wrapper { padding: 20px; }
}

@media (max-width: 768px) {
    .upload-grid { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
}
