/* CSS Variables for Premium Theme */
:root {
    /* Modern Color Palette: Emerald/Teal for Health & Energy */
    --primary-50: #ecfdf5;
    /* Emerald 50 */
    --primary-100: #d1fae5;
    /* Emerald 100 */
    --primary-500: #10b981;
    /* Emerald 500 */
    --primary-600: #059669;
    /* Emerald 600 */
    --primary-700: #047857;
    /* Emerald 700 */

    --secondary-500: #64748b;
    /* Slate 500 */

    --bg-body: #f8fafc;
    /* Slate 50 */
    --bg-card: #ffffff;

    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */

    --border-color: #e2e8f0;
    /* Slate 200 */

    --success-bg: #dcfce7;
    --success-text: #166534;

    --warning-bg: #fef3c7;
    --warning-text: #92400e;

    --danger-bg: #fee2e2;
    --danger-text: #991b1b;

    /* Dimensions */
    --sidebar-width: 280px;
    --header-height: 70px;

    /* Effects */
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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);

    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: 1px solid rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

/* Layout */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100%;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
    border-bottom: 1px solid var(--border-color);
}

.nav-menu {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-link:hover {
    background-color: var(--primary-50);
    color: var(--primary-600);
    transform: translateX(5px);
}

.nav-link.active {
    background-color: var(--primary-50);
    color: var(--primary-600);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 24px;
    width: 4px;
    background-color: var(--primary-600);
    border-radius: 0 4px 4px 0;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    border-radius: 999px;
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding-right: 4px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    padding-left: 1rem;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

/* Container */
.container {
    padding: 2rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.6s ease-out;
}

/* Typography & Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    animation: slideUp 0.5s ease-out;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.025em;
    background: linear-gradient(to right, var(--text-main), var(--secondary-500));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-100);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
    animation-fill-mode: both;
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-100);
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -1px;
}

/* Status Badges */
.status-badge {
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

.status-active,
.status-paid,
.status-converted {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.status-inactive,
.status-unpaid,
.status-closed {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

.status-pending,
.status-new,
.status-contacted {
    background-color: var(--warning-bg);
    color: var(--warning-text);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary-500);
    color: var(--primary-600);
    background-color: var(--primary-50);
}

.btn-danger {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

.btn-danger:hover {
    background-color: #fecaca;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8125rem;
    border-radius: 0.5rem;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.data-table th {
    background-color: var(--bg-body);
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-main);
    transition: background-color 0.2s;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover td {
    background-color: var(--primary-50);
}

/* Advanced Animations */
@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(30px, -50px) rotate(10deg);
    }

    66% {
        transform: translate(-20px, 20px) rotate(-5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

@keyframes shine {
    0% {
        transform: translateX(-100%) skewX(-15deg);
    }

    100% {
        transform: translateX(200%) skewX(-15deg);
    }
}

/* Enhanced Login Styles */
.login-body {
    background: linear-gradient(135deg, #f0f4f4 0%, #ecfdf5 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Animated Background Shapes */
.shape {
    position: absolute;
    filter: blur(50px);
    z-index: 0;
    animation: float 20s infinite ease-in-out;
    opacity: 0.6;
}

.shape-1 {
    top: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-500), #34d399);
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
}

.shape-2 {
    bottom: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #2dd4bf, #059669);
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    animation-delay: -5s;
}

.shape-3 {
    top: 40%;
    left: 40%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #6ee7b7, #047857);
    border-radius: 50%;
    animation-delay: -10s;
    opacity: 0.4;
}

.login-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

    /* Search & Filters */
    .search-wrapper {
        display: flex;
        gap: 0.75rem;
        align-items: center;
        background: white;
        padding: 0.5rem;
        border-radius: var(--radius-lg);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        border: 1px solid var(--border-color);
        transition: all 0.3s ease;
    }

    .search-wrapper:focus-within {
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
        border-color: var(--primary-500);
    }

    .search-form {
        display: flex;
        align-items: center;
        width: 100%;
    }

    .search-icon {
        color: var(--text-muted);
        margin-left: 0.75rem;
    }

    .search-input {
        border: none;
        outline: none;
        padding: 0.5rem 0.75rem;
        font-size: 0.95rem;
        width: 100%;
        color: var(--text-main);
    }

    .search-input::placeholder {
        color: #94a3b8;
    }

    .search-btn {
        background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
        color: white;
        border: none;
        border-radius: var(--radius-md);
        padding: 0.5rem 1rem;
        font-weight: 600;
        font-size: 0.85rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .search-btn:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-sm);
    }

    border-radius: 2rem;
    position: relative;
    z-index: 10;
    max-width: 420px;
    width: 90%;
    transform: translateY(0);
    transition: transform 0.3s ease,
    box-shadow 0.3s ease;
}

.login-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.2);
}

/* Floating Input Labels */
.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-field {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    /* Left padding for icon */
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid transparent;
    border-radius: 1rem;
    font-size: 1rem;
    color: var(--text-main);
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.input-field:placeholder-shown+.input-label {
    /* Styles when placeholder is shown (if we used one, but we hide it for this effect) */
}

/* Focus and Filled States */
.input-field:focus {
    outline: none;
    background: white;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s ease;
    z-index: 2;
}

.input-field:focus~.input-icon {
    color: var(--primary-600);
}

/* Enhanced Button */
.btn-login {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 1rem;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(16, 185, 129, 0.4);
}

.btn-login::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 100%);
    transform: skewX(-25deg);
    animation: shine 3s infinite;
}

.login-title {
    font-size: 2rem;
    margin-bottom: 2.5rem;
    font-weight: 800;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.5rem;
    }

    .container {
        padding: 1rem;
    }

    /* Mobile Overlay */
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 45;
        /* Below sidebar (50) but above everything else */
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        backdrop-filter: blur(2px);
    }

    .overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile Toggle Visibility */
    #sidebarToggle {
        display: inline-flex !important;
    }

    .mobile-page-title {
        display: block !important;
    }

    .top-header {
        display: none;
        /* Hide top header on mobile to save space, rely on internal title */
    }

    /* Stack Tables on Mobile */
    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        margin-bottom: 1rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 1rem;
        box-shadow: var(--shadow-sm);
    }

    .data-table td {
        text-align: right;
        padding-left: 50% !important;
        position: relative;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .data-table td:last-child {
        border-bottom: none;
        justify-content: flex-end;
    }
}