@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Vibrant Color Essence */
    --primary: #4338ca;
    /* Rich Indigo */
    --primary-dark: #312e81;
    --primary-light: #6366f1;
    --accent: #8b5cf6;
    /* Vibrant Violet */
    --accent-glow: rgba(139, 92, 246, 0.3);

    --success: #10b981;
    /* Emerald */
    --success-glow: rgba(16, 185, 129, 0.25);
    --warning: #f59e0b;
    /* Amber */
    --warning-glow: rgba(245, 158, 11, 0.2);
    --error: #f43f5e;
    /* Rose */
    --error-glow: rgba(244, 63, 94, 0.2);

    --bg-main: #fcfcfd;
    /* Pristine White-Gray */
    --bg-sidebar: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    --bg-card: #ffffff;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-white: #ffffff;

    --border: rgba(226, 232, 240, 0.8);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Sophisticated Shadows */
    --shadow-subtle: 0 1px 3px 0 rgba(0, 0, 0, 0.02);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.06);
    --shadow-vibrant: 0 10px 25px -5px var(--accent-glow);

    /* Gradients */
    --grad-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Overhaul */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
    padding: 40px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.sidebar-brand span {
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sidebar-nav {
    flex: 1;
    padding: 0 16px;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    border-radius: var(--radius-md);
    transition: all 0.3s;
    border: 1px solid transparent;
}

.sidebar-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(4px);
    transform: translateX(4px);
}

.sidebar-nav a.active {
    color: #fff;
    background: var(--grad-primary);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-nav i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    transition: transform 0.3s;
}

.sidebar-nav a:hover i {
    transform: scale(1.2);
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Top Header Glassmorphism */
.top-header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(200%);
    -webkit-backdrop-filter: blur(20px) saturate(200%);
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 90;
}

.top-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.03em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 32px;
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-welcome {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--error);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    transition: all 0.3s;
    background: rgba(244, 63, 94, 0.05);
    border: 1px solid transparent;
}

.logout-btn:hover {
    background: var(--error);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--error-glow) 0 8px 20px;
}

/* Content Body */
.content-body {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Cards & Stats Overhaul */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 32px;
    margin-bottom: 48px;
}

.stat-card {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.4s;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(5deg);
}

.stat-icon.blue {
    background: #eff6ff;
    color: #3b82f6;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.15);
}

.stat-icon.green {
    background: #ecfdf5;
    color: #10b981;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.15);
}

.stat-icon.amber {
    background: #fffbeb;
    color: #f59e0b;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.15);
}

.stat-icon.red {
    background: #fef2f2;
    color: #f43f5e;
    box-shadow: 0 8px 20px rgba(244, 63, 94, 0.15);
}

.stat-body h3 {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.stat-body p {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.04em;
    margin: 0;
}

/* Invoices Tables Overhaul */
.recent-invoices {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow 0.3s;
}

.recent-invoices:hover {
    box-shadow: var(--shadow-lg);
}

.section-header {
    padding: 32px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(248, 250, 252, 0.5);
}

.section-header h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    background: #fcfdfe;
    padding: 20px 40px;
    text-align: left;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 24px 40px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    color: #475569;
    vertical-align: middle;
    transition: all 0.3s;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(99, 102, 241, 0.02);
    color: var(--primary-dark);
}

.customer-name {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 2px;
}

.customer-email {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.amount-cell {
    font-weight: 800;
    color: var(--primary);
    font-size: 16px;
    letter-spacing: -0.02em;
}

/* Status Chips */
.status-select {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.status-pending {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.status-paid {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.status-cancelled {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.status-select:hover {
    transform: scale(1.05);
    filter: brightness(0.95);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.btn-secondary {
    background: #fff;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--primary);
}

/* Forms Overhaul */
.invoice-form-container {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
    border: 1px solid var(--border);
}

.form-section {
    margin-bottom: 48px;
}

.form-section h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 28px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-control {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--primary);
    background: #fdfdfd;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus {
    outline: none;
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.08);
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 10px;
}

/* Action Buttons */
.action-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    margin-right: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
}

.action-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

.action-btn.delete:hover {
    background: var(--error);
    border-color: var(--error);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
}

/* DataTables Premium Styling Refinements */
.data-table thead th {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 16px 20px !important;
    border-bottom: 2px solid var(--border) !important;
    background: #f8fafc !important;
}

/* Custom Sorting Indicators */
.dt-column-order {
    display: none !important;
}

.data-table thead th.dt-ordering-asc::after,
.data-table thead th.dt-ordering-desc::after {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: 8px;
    font-size: 10px;
}

.data-table thead th.dt-ordering-asc::after {
    content: "\f0de";
}

.data-table thead th.dt-ordering-desc::after {
    content: "\f0dd";
}

/* Layout & Alignment */
.dt-container .dt-layout-row {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dt-container .dt-search {
    margin: 0 !important;
    padding: 0 40px !important;
}

.dt-container .dt-length {
    padding: 0 40px !important;
}

.dt-length select {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 6px 10px !important;
    font-family: inherit !important;
    font-size: 13px !important;
    color: var(--primary) !important;
    margin: 0 8px !important;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-body {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive Utilities Overhaul */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }

    .sidebar-brand h2,
    .sidebar-nav a span {
        display: none;
    }

    .sidebar-brand {
        justify-content: center;
        padding: 24px 0;
    }

    .sidebar-nav {
        padding: 0 8px;
    }

    .sidebar-nav a {
        justify-content: center;
        padding: 16px 0;
    }

    .sidebar-nav i {
        font-size: 20px;
        margin: 0;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 1000;
        border-right: none;
        border-top: 1px solid var(--border);
        background: var(--primary) !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    }

    .sidebar-brand {
        display: none;
    }

    .sidebar-nav ul {
        display: flex;
        justify-content: space-around;
        padding: 8px 0;
        margin: 0;
    }

    .sidebar-nav li {
        margin: 0;
    }

    .sidebar-nav a {
        flex-direction: column;
        gap: 4px;
        padding: 8px !important;
        border-radius: 0;
        background: transparent !important;
    }

    .sidebar-nav a.active {
        color: var(--accent);
    }

    .sidebar-nav a span {
        display: block !important;
        font-size: 10px;
        opacity: 1;
    }

    .sidebar-nav a i {
        font-size: 18px;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-bottom: 80px;
    }

    .top-header {
        padding: 16px 20px;
        position: sticky;
        top: 0;
        z-index: 900;
        background: var(--bg-main);
        backdrop-filter: blur(10px);
    }

    .content-body {
        padding: 16px;
    }

    /* Form Rows on Mobile */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Table Scrolling */
    .recent-invoices {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .data-table {
        min-width: 850px !important;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .dt-search {
        padding: 0 16px !important;
    }

    .dt-search input {
        width: 100% !important;
    }

    .dt-paging {
        padding: 16px !important;
        justify-content: center !important;
    }

    .dt-layout-row {
        flex-direction: column !important;
        gap: 12px !important;
    }
}

@media (max-width: 480px) {
    .top-header h1 {
        font-size: 18px;
    }

    .user-welcome {
        display: none;
    }

    .user-info {
        gap: 12px;
    }

    .logout-btn span {
        display: none;
    }

    .logout-btn {
        padding: 8px;
    }

    .stat-card {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sidebar-nav ul {
        display: flex;
        overflow-x: auto;
        padding-bottom: 12px;
    }

    .sidebar-nav li {
        margin: 0 4px;
    }

    .content-body {
        padding: 20px;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }
}