/*
 * Antigravity Premium Dashboard Theme
 * Custom Glassmorphic Dark-Modern Web System
 */

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

:root {
    --bg-base: #0b0c16;
    --bg-surface: #121324;
    --bg-glass: rgba(18, 19, 36, 0.65);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.35);
    --primary-dark: #6d28d9;
    
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.25);
    --accent-rose: #f43f5e;
    --accent-rose-glow: rgba(244, 63, 94, 0.25);
    --accent-amber: #f59e0b;
    --accent-indigo: #3b82f6;

    --font-sans: 'Outfit', sans-serif;
    --sidebar-width: 280px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition-smooth);
}

.sidebar-brand {
    padding: 30px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent-indigo));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.brand-icon svg {
    color: white;
    width: 22px;
    height: 22px;
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    padding: 0 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.sidebar-menu li a svg {
    width: 20px;
    height: 20px;
    transition: var(--transition-smooth);
}

.sidebar-menu li a:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.sidebar-menu li.active a {
    background: linear-gradient(135deg, var(--primary), rgba(139, 92, 246, 0.4));
    color: white;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.25);
}

.sidebar-menu li.active a svg {
    transform: scale(1.1);
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-glass);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #252849;
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: text-overflow;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--accent-rose);
    text-decoration: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    font-weight: 600;
    opacity: 0.8;
    transition: var(--transition-smooth);
}

.logout-btn:hover {
    opacity: 1;
    transform: translateX(2px);
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    padding: 40px;
    transition: var(--transition-smooth);
}

/* Collapsed Sidebar Rules */
body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}
body.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* Alert Boxes */
.alert {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 30px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    border-left: 5px solid var(--accent-emerald);
    background: linear-gradient(to right, rgba(16, 185, 129, 0.08), transparent);
}

.alert-danger {
    border-left: 5px solid var(--accent-rose);
    background: linear-gradient(to right, rgba(244, 63, 94, 0.08), transparent);
}

.alert-warning {
    border-left: 5px solid var(--accent-amber);
    background: linear-gradient(to right, rgba(245, 158, 11, 0.08), transparent);
}

.alert-info {
    border-left: 5px solid var(--accent-indigo);
    background: linear-gradient(to right, rgba(59, 130, 246, 0.08), transparent);
}

.btn-close-alert {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
}

/* Cards & Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.stat-card:hover::before {
    opacity: 1;
}

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

.stat-value {
    font-size: 26px;
    font-weight: 700;
    margin-top: 8px;
    background: linear-gradient(to right, #fff, #e9d5ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.stat-icon.emerald {
    color: var(--accent-emerald);
}

.stat-icon.rose {
    color: var(--accent-rose);
}

.stat-icon.amber {
    color: var(--accent-amber);
}

.stat-icon.indigo {
    color: var(--accent-indigo);
}

/* Glass Card Container */
.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

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

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-success, .btn-warning {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
    background: linear-gradient(135deg, #9b6bf7, var(--primary));
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
    color: white;
    box-shadow: 0 4px 15px var(--accent-emerald-glow);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-rose), #e11d48);
    color: white;
    box-shadow: 0 4px 15px var(--accent-rose-glow);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 63, 94, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.table-custom th {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-glass);
}

.table-custom td {
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--border-glass);
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 14px;
}

.table-custom td:first-child {
    border-left: 1px solid var(--border-glass);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.table-custom td:last-child {
    border-right: 1px solid var(--border-glass);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.table-custom tr {
    transition: var(--transition-smooth);
}

.table-custom tbody tr:hover td {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(139, 92, 246, 0.2);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-draft {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.badge-sent {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-indigo);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-paid {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-cancelled {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control, .form-select, textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: var(--transition-smooth);
}

.form-control:focus, .form-select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(0, 0, 0, 0.3);
}

.form-select option {
    background-color: var(--bg-surface);
    color: white;
}

/* Grid helper for forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition-smooth);
}

.modal-backdrop.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    width: 90%;
    max-width: 600px;
    padding: 30px;
    position: relative;
    transform: scale(0.9);
    transition: var(--transition-smooth);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-glass);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 24px;
}

/* Dynamic Item Creator Table */
.creator-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.creator-table th {
    text-align: left;
    padding: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.creator-table td {
    padding: 10px 5px;
}

.remove-item-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.remove-item-btn:hover {
    background: var(--accent-rose);
    color: white;
}

/* Login Page Layout */
.login-container {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 28px;
    width: 100%;
    max-width: 440px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .brand-icon {
    margin: 0 auto 16px auto;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: white;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

/* Summary Box in Proforma Creator */
.summary-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px;
    width: 320px;
    margin-left: auto;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.summary-row.total {
    border-top: 1px solid var(--border-glass);
    padding-top: 10px;
    margin-top: 10px;
    font-size: 18px;
    font-weight: 700;
    color: white;
}

/* Mobile Sidebar Hamburger Toggle */
.mobile-header {
    display: none;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-glass);
    padding: 16px 20px;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 101;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

/* Responsive Utilities */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
        padding: 20px;
    }
    
    .mobile-header {
        display: flex;
    }
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .top-bar .action-buttons {
        width: 100%;
    }
    
    .top-bar .action-buttons button,
    .top-bar .action-buttons a {
        flex-grow: 1;
        justify-content: center;
    }
    
    .creator-table th:nth-child(3),
    .creator-table td:nth-child(3),
    .creator-table th:nth-child(4),
    .creator-table td:nth-child(4) {
        display: none; /* Hide Description & Unit on extra small screens */
    }
    
    .summary-container {
        width: 100%;
    }
}
