/* iZafox Billing - Corporate SaaS Theme */
:root {
    --navy-900: #0a1628;
    --navy-800: #0f2137;
    --navy-700: #152a45;
    --navy-600: #1c3554;
    --navy-500: #234163;
    --orange-500: #f97316;
    --orange-600: #ea580c;
    --orange-400: #fb923c;
    --accent-glow: rgba(249, 115, 22, 0.25);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(255, 255, 255, 0.08);
    --card-bg: rgba(15, 33, 55, 0.85);
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--navy-900);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.text-accent { color: var(--orange-500) !important; }

/* Login */
.login-page {
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 50%, var(--navy-900) 100%);
    z-index: 0;
}

.login-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    animation: pulse-glow 4s ease-in-out infinite;
}

.login-bg::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(249,115,22,0.1) 0%, transparent 70%);
    animation: pulse-glow 6s ease-in-out infinite reverse;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; }
}

.login-card {
    position: relative;
    z-index: 1;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
}

.login-logo img {
    height: 56px;
    margin-bottom: 0.5rem;
}

.login-logo-fallback {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
    margin: 0 auto 0.5rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.login-footer {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* App Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--navy-800);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo {
    height: 32px;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.125rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    font-size: 1.125rem;
    width: 24px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav .nav-link.active {
    color: white;
    background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
    box-shadow: 0 4px 15px var(--accent-glow);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--navy-600);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--orange-500);
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--navy-800);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.page-heading {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.content-area {
    flex: 1;
    padding: 1.5rem;
}

.app-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}

/* Cards & Stats */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
    transition: var(--transition);
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(249, 115, 22, 0.3);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.stat-icon.orange { background: rgba(249, 115, 22, 0.15); color: var(--orange-500); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.stat-icon.green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.stat-icon.purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.card-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}

.card-panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-panel-header h5 {
    margin: 0;
    font-weight: 600;
}

.card-panel-body {
    padding: 1.5rem;
}

.card-panel-body.no-padding {
    padding: 0;
}

/* Tables */
.table-dark-custom {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    margin: 0;
}

.table-dark-custom thead th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table-dark-custom tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table-dark-custom tbody tr {
    transition: var(--transition);
}

.table-dark-custom tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Forms */
.form-control, .form-select {
    background: var(--navy-700);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 0.625rem 0.875rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    background: var(--navy-600);
    border-color: var(--orange-500);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.input-group-text {
    background: var(--navy-600);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 10px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
    border: none;
    border-radius: 10px;
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    transition: var(--transition);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--orange-400), var(--orange-500));
    box-shadow: 0 4px 15px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-outline-light {
    border-color: var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    transition: var(--transition);
}

.btn-action.view { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.btn-action.edit { background: rgba(249, 115, 22, 0.15); color: var(--orange-500); }
.btn-action.delete { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.btn-action.pdf { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

.btn-action:hover { transform: scale(1.1); }

/* Badges */
.badge-status {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-sent { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-paid { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.badge-draft { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.badge-cancelled { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.badge-type-product { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.badge-type-service { background: rgba(249, 115, 22, 0.15); color: var(--orange-500); }

/* Search */
.search-box {
    position: relative;
    max-width: 320px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding-left: 2.5rem;
}

/* Modal */
.modal-content {
    background: var(--navy-800);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-primary);
}

.modal-header { border-bottom-color: var(--border-color); }
.modal-footer { border-top-color: var(--border-color); }

.btn-close { filter: invert(1); }

/* Invoice Form */
.invoice-lines-table input, .invoice-lines-table select {
    font-size: 0.875rem;
}

.line-total-display {
    font-weight: 600;
    color: var(--orange-500);
}

.totals-panel {
    background: var(--navy-700);
    border-radius: 12px;
    padding: 1.25rem;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    color: var(--text-secondary);
}

.totals-row.grand-total {
    border-top: 2px solid var(--orange-500);
    margin-top: 0.5rem;
    padding-top: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.totals-row.grand-total span:last-child {
    color: var(--orange-500);
}

/* Invoice Preview */
.invoice-preview {
    background: white;
    color: #1e293b;
    border-radius: 12px;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.invoice-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f97316;
}

.invoice-preview-logo img {
    max-height: 60px;
}

.invoice-preview-number {
    text-align: right;
}

.invoice-preview-number h2 {
    color: #f97316;
    font-size: 1.5rem;
    margin: 0;
}

.invoice-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.invoice-info-block h6 {
    color: #f97316;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.invoice-preview-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.invoice-preview-table th {
    background: #0f2137;
    color: white;
    padding: 0.75rem;
    text-align: left;
    font-size: 0.8125rem;
}

.invoice-preview-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
}

.invoice-preview-totals {
    display: flex;
    justify-content: flex-end;
}

.invoice-preview-totals table {
    width: 280px;
}

.invoice-preview-totals td {
    padding: 0.375rem 0;
    font-size: 0.875rem;
}

.invoice-preview-totals .total-row td {
    font-weight: 700;
    font-size: 1.125rem;
    color: #f97316;
    border-top: 2px solid #f97316;
    padding-top: 0.75rem;
}

.invoice-qr-preview {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

/* Settings */
.logo-preview {
    width: 120px;
    height: 120px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--navy-700);
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Animations */
.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Alert */
.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Toast override */
.toast {
    background: var(--navy-700);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .invoice-info-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    body * { visibility: hidden; }
    .invoice-preview, .invoice-preview * { visibility: visible; }
    .invoice-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .no-print { display: none !important; }
}
