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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* Login */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 48px 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

.login-box h1 {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-box h2 {
    text-align: center;
    font-size: 0.95rem;
    color: var(--gray-500);
    margin-bottom: 32px;
    font-weight: 400;
}

/* Navigation */
.navbar {
    background: white;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-brand::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    color: var(--gray-600);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--primary);
    background: var(--gray-100);
}

.nav-link.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

.user-info {
    font-size: 0.875rem;
    color: var(--gray-500);
    padding: 0 16px;
    border-left: 1px solid var(--gray-200);
}

/* Container */
.container {
    max-width: 1280px;
    margin: 40px auto;
    padding: 0 24px;
}

/* Headings */
h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 24px;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
}

h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
}

.customer-number {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Forms */
.customer-form {
    background: white;
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.form-card {
    background: white;
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
}

select, input[type="text"], input[type="password"], input[type="month"], input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: inherit;
    background: white;
}

select:hover, input:hover {
    border-color: var(--gray-300);
}

select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-small {
    padding: 10px 14px;
    font-size: 0.9rem;
}

textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-error, .alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Tables */
.data-table {
    width: 100%;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-top: 20px;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th,
.data-table td {
    padding: 16px 20px;
    text-align: left;
}

.data-table th {
    background: linear-gradient(135deg, var(--gray-700) 0%, var(--gray-800) 100%);
    color: white;
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table th:first-child {
    border-top-left-radius: var(--radius);
}

.data-table th:last-child {
    border-top-right-radius: var(--radius);
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:nth-child(even) {
    background: var(--gray-50);
}

.data-table tbody tr:hover {
    background: rgba(79, 70, 229, 0.04);
}

.data-table td {
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}

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

.key-cell {
    font-weight: 600;
    color: var(--primary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.badge-wholesaler {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    margin-right: 6px;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
}

/* Section Titles */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 32px 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

/* Invoice Section */
.invoice-section {
    margin-bottom: 32px;
}

.invoice-section h5 {
    margin-bottom: 12px;
    color: var(--gray-700);
    font-size: 0.95rem;
    font-weight: 600;
}

/* Customer Header */
.customer-header {
    margin-top: 32px;
    padding: 24px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.customer-header h3 {
    font-size: 1.5rem;
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 16px;
    padding: 14px 18px;
    background: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.filter-bar label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.filter-bar select {
    width: auto;
    min-width: 180px;
    padding: 8px 14px;
    font-size: 0.875rem;
}

/* Debug Toggle */
.debug-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 8px 14px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--gray-600);
    transition: all 0.2s;
}

.debug-toggle:hover {
    background: var(--gray-200);
}

.debug-toggle input {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.debug-toggle.active span {
    color: var(--primary);
    font-weight: 500;
}

/* Progress */
.progress-container {
    margin: 32px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 10px;
    transition: width 0.4s ease;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Form Elements */
.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.checkbox-group {
    margin-bottom: 24px;
}

.checkbox-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-100);
}

.checkbox-item label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    width: auto;
    accent-color: var(--primary);
}

.checkbox-item input[type="text"] {
    margin-top: 8px;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Result Cells */
.result-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.formula {
    font-size: 0.8rem;
    color: var(--gray-400);
    font-family: 'Monaco', 'Consolas', monospace;
}

/* Actions */
.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form {
    display: inline;
}

/* Utilities */
.text-muted {
    color: var(--gray-400);
}

.no-data {
    text-align: center;
    padding: 48px;
    color: var(--gray-500);
    background: white;
    border-radius: var(--radius);
    margin-top: 20px;
    font-size: 0.95rem;
}

.inactive-row {
    opacity: 0.6;
}

/* Debug Info */
.debug-info {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    background: #1e1e2e !important;
    color: #a6e3a1;
    padding: 20px !important;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header-actions {
    display: flex;
    gap: 10px;
}

/* Credentials Form */
.credentials-form {
    margin-top: 20px;
}

.credentials-form .data-table {
    margin-top: 0;
}

.credentials-form .form-actions {
    margin-top: 20px;
    justify-content: flex-start;
}

/* Subsection */
.subsection-title {
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* Analysis Summary */
.analysis-summary-section {
    margin-top: 32px;
}

/* Tabs */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    background: white;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.tab:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .data-table, .customer-header {
    animation: fadeIn 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 0 16px;
        height: auto;
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }
    
    .nav-links {
        flex-wrap: wrap;
    }
    
    .user-info {
        border-left: none;
        padding: 0;
        width: 100%;
        order: 3;
    }
    
    .container {
        padding: 0 16px;
        margin: 20px auto;
    }
    
    .customer-form {
        flex-direction: column;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .data-table {
        display: block;
        overflow-x: auto;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}
