/* Modern Professional Fintech Theme */
:root {
    /* Sophisticated, neutral background palette */
    --bg-primary: #F8FAFC; /* Slate 50 */
    --bg-secondary: #FFFFFF; /* Pure White */
    
    /* High contrast text for readability */
    --text-primary: #0F172A; /* Slate 900 */
    --text-secondary: #64748B; /* Slate 500 */
    
    /* Trustworthy Indigo for primary actions */
    --accent-primary: #4F46E5; /* Indigo 600 */
    --accent-hover: #4338CA; /* Indigo 700 */
    --accent-light: #EEF2FF; /* Indigo 50 */
    
    /* Semantic colors with soft backgrounds */
    --success: #10B981; /* Emerald 500 */
    --success-bg: #ECFDF5;
    --warning: #F59E0B; /* Amber 500 */
    --warning-bg: #FFFBEB;
    --danger: #EF4444; /* Red 500 */
    --danger-bg: #FEF2F2;
    
    /* Subtle structural elements */
    --border-color: #E2E8F0; /* Slate 200 */
    --border-width: 1px;
    --border-radius-lg: 12px;
    --border-radius: 8px;
    --border-radius-sm: 6px;
    
    /* Premium diffused shadows */
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.05), 0 4px 6px -2px rgba(15, 23, 42, 0.025);
    --shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

input, button {
    font-family: inherit;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: var(--border-width) solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 20;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
}

.logo {
    width: 32px;
    height: 32px;
    background-image: url('../images/logo.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--border-radius-sm);
}

.logo-container h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.625rem 1rem;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: #F1F5F9; /* Slate 100 */
}

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

.nav-item.active .icon {
    color: var(--accent-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1.25rem 0.5rem 0.5rem 0.5rem;
    border-top: var(--border-width) solid var(--border-color);
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--accent-light);
    color: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}
.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Timeline */
.timeline {
    margin-top: 2rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
}
.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    transform: translateX(-50%);
    border: 2px solid #fff;
}
.timeline-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.timeline-content {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-secondary);
    border-bottom: var(--border-width) solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border: var(--border-width) solid transparent;
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    width: 320px;
    transition: all 0.2s ease;
}

.search-bar:focus-within {
    background-color: var(--bg-secondary);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

.search-bar input {
    background: none;
    border: none;
    outline: none;
    width: 100%;
    margin-left: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.search-bar input::placeholder {
    color: #94A3B8; /* Slate 400 */
}

.actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn {
    padding: 0.625rem 1.25rem;
    border: var(--border-width) solid transparent;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--bg-primary);
    border-color: #CBD5E1; /* Slate 300 */
}

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

.btn-danger:hover {
    background-color: #DC2626; /* Red 600 */
    box-shadow: var(--shadow-md);
}

.btn-outline-danger {
    background-color: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-outline-danger:hover {
    background-color: var(--danger-bg);
    color: #DC2626;
    border-color: #DC2626;
}

.icon-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 1.125rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background-color: #F1F5F9;
    color: var(--text-primary);
}

.dashboard-content {
    padding: 2.5rem;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background-color: var(--bg-secondary);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.stat-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.trend {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
}

.trend.positive { color: var(--success); background-color: var(--success-bg); }
.trend.negative { color: var(--danger); background-color: var(--danger-bg); }

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

/* Sections & Tables */
.recent-section, .invoice-form-container {
    background-color: var(--bg-secondary);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.view-all {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent-primary);
}
.view-all:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.table-container {
    overflow-x: auto;
    margin: -2rem;
    margin-top: 0;
    padding: 2rem;
    padding-top: 0;
}

.data-table, .items-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .items-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background-color: #F8FAFC;
    border-bottom: var(--border-width) solid var(--border-color);
}

.data-table td, .items-table td {
    padding: 1.25rem 1.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: var(--border-width) solid var(--border-color);
}

.table-center th, .table-center td {
    text-align: center !important;
}

.data-table tbody tr:hover td {
    background-color: #F8FAFC;
}

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

.status {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
}

.status.paid { color: #065F46; background-color: var(--success-bg); }
.status.pending { color: #92400E; background-color: var(--warning-bg); }
.status.overdue { color: #991B1B; background-color: var(--danger-bg); }

/* Invoice Generator Specifics */
.form-section {
    margin-bottom: 2.5rem;
}

.form-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    letter-spacing: -0.025em;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group input, .items-table input {
    background-color: var(--bg-secondary);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.form-group input:focus, .items-table input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

.items-table-container {
    margin-bottom: 1.5rem;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.col-desc { width: 45%; }
.col-qty { width: 10%; }
.col-price { width: 15%; }
.col-total { width: 20%; font-weight: 600; }
.col-action { width: 10%; text-align: center; }

.item-row-total {
    font-weight: 600;
}

.btn-remove-item {
    background-color: transparent;
    color: #94A3B8;
    border: none;
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}

.btn-remove-item:hover {
    color: var(--danger);
    background-color: var(--danger-bg);
}

.summary-section {
    display: flex;
    justify-content: flex-end;
}

.summary-box {
    width: 380px;
    background-color: #F8FAFC;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.summary-row.total-row {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: var(--border-width) solid var(--border-color);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.tax-input {
    width: 80px;
    text-align: right;
}

/* Login Page Styles */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 2rem;
}

.login-card {
    background-color: var(--bg-secondary);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    justify-content: center;
    margin-bottom: 1.5rem;
}

.login-logo .logo {
    width: 40px;
    height: 40px;
}

.login-logo h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.login-subtitle {
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.btn-block {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.error-message {
    color: #991B1B;
    background-color: var(--danger-bg);
    border-radius: var(--border-radius-sm);
    text-align: center;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: none;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Print / PDF Generation Styles */
@media print {
    .sidebar, .topbar, .actions, button, .btn-remove-item, #addItemBtn, .page-header button, #historySection {
        display: none !important;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .app-container {
        display: block !important;
        background: white !important;
    }
    body {
        background: white !important;
        color: black !important;
    }
    input, select, textarea {
        border: none !important;
        background: transparent !important;
        color: black !important;
        -webkit-appearance: none;
        appearance: none;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }
    .dashboard-content, .invoice-form-container, .form-section, .summary-box {
        box-shadow: none !important;
        border: none !important;
        background: white !important;
        padding: 0 !important;
        margin-bottom: 20px !important;
    }
    .page-title {
        color: black !important;
    }
    /* Ensure colors print properly */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .summary-box {
        margin-top: 2rem !important;
        border-top: 2px solid black !important;
    }
}
