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

:root {
    --primary: #4F46E5;
    --primary-dark: #4338ca;
    --secondary: #10B981;
    --dark: #111827;
    --light: #F9FAFB;
    --gray: #6B7280;
    --border: #E5E7EB;
    --danger: #EF4444;
    --warning: #F59E0B;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: #F3F4F6;
    color: #1F2937;
    line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--dark);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 0;
    flex: 1;
    overflow-y: auto;
}

/* Custom Scrollbar for Sidebar */
.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: #9CA3AF;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background: rgba(79, 70, 229, 0.1);
    color: white;
}

.sidebar-menu a.active {
    background: var(--primary);
}

.sidebar-menu a i {
    width: 24px;
    margin-right: 12px;
}

/* Submenu Styles */
.has-submenu {
    position: relative;
}

.submenu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.submenu-toggle .arrow {
    font-size: 0.8em;
    transition: transform 0.3s ease;
    margin-right: 0 !important;
    width: auto !important;
}

.has-submenu.open .submenu-toggle .arrow {
    transform: rotate(180deg);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: rgba(0, 0, 0, 0.2);
    list-style: none;
    padding: 0;
}

.has-submenu.open .submenu {
    max-height: 500px; /* Arbitrary large height */
    transition: max-height 0.5s ease-in;
}

.submenu li a {
    padding-left: 52px;
    font-size: 0.9em;
    color: #9CA3AF;
}

.submenu li a:hover, .submenu li a.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    width: calc(100% - 260px);
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.mobile-nav-toggle {
    display: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 8px 16px;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.user-info:hover {
    background: #f9fafb;
}

/* User Profile Dropdown */
.user-profile-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: white;
    min-width: 180px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 8px;
    display: none;
    z-index: 1000;
}

.dropdown-menu.show {
    display: block;
    animation: fadeInDropdown 0.2s ease-out;
}

@keyframes fadeInDropdown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.dropdown-menu a:hover {
    background: #f3f4f6;
    color: var(--primary);
}

.dropdown-menu a i {
    font-size: 16px;
    color: var(--gray);
    width: 20px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.logout-link {
    color: var(--danger) !important;
}

.logout-link:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}

.logout-link i {
    color: var(--danger) !important;
}

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

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

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

.stat-card h3 {
    color: var(--gray);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

/* Stat Icons */
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 20px;
}

.stat-icon.blue { background: #DBEAFE; color: #1E40AF; }
.stat-icon.green { background: #D1FAE5; color: #065F46; }
.stat-icon.orange { background: #FFEDD5; color: #9A3412; }
.stat-icon.purple { background: #E9D5FF; color: #6B21A8; }
.stat-icon.indigo { background: #E0E7FF; color: #3730A3; }
.stat-icon.teal { background: #CCFBF1; color: #115E59; }
.stat-icon.red { background: #FEE2E2; color: #991B1B; }
.stat-icon.amber { background: #FEF3C7; color: #92400E; }

/* Charts Section */
.charts-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

@media (max-width: 1024px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

/* Tables */
.table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}

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

.table-header h2 {
    font-size: 18px;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #F9FAFB;
    text-align: left;
    padding: 12px 24px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray);
    letter-spacing: 0.05em;
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    color: var(--dark);
    font-size: 14px;
}

tr:last-child td {
    border-bottom: none;
}

/* Buttons */
.btn, .btn-primary, .btn-secondary, .btn-danger, .btn-outline-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent; /* Changed from none to allow borders */
    text-decoration: none;
    line-height: 1.5; /* Ensure consistent height */
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--dark);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
}

.btn-outline-primary {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

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

.btn-danger:hover {
    background: #DC2626;
}

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

/* Forms */
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
}

/* Status Badges */
.status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-paid {
    background: #D1FAE5;
    color: #065F46;
}

.status-pending {
    background: #FEF3C7;
    color: #92400E;
}

.status-overdue {
    background: #FEE2E2;
    color: #991B1B;
}

/* Invoice Form Specifics */
.invoice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.invoice-card {
    background: white;
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Invoice Items Table */
.items-table {
    width: 100%;
    margin-bottom: 24px;
}

.items-table th {
    background: #F9FAFB;
    padding: 12px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray);
    font-weight: 600;
}

.items-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.item-row:hover {
    background-color: #f9fafb;
}

.item-total-val {
    font-weight: 600;
    text-align: right;
    padding-top: 10px;
}

.totals-section {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.totals-card {
    width: 300px;
    background: #F9FAFB;
    padding: 20px;
    border-radius: 12px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--gray);
}

.total-row.final {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
}

/* Product Search */
.product-search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.search-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: #F3F4F6;
}

.search-item .price {
    float: right;
    font-weight: 600;
    color: var(--primary);
}

.search-item .stock {
    font-size: 12px;
    color: var(--gray);
    display: block;
}

/* Client Search */
.client-search-container {
    position: relative;
    margin-bottom: 16px;
}

.client-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.client-search-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.client-search-item:last-child {
    border-bottom: none;
}

.client-search-item:hover {
    background: #F3F4F6;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }
    
    .mobile-nav-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: var(--dark);
        padding: 4px;
    }

    .invoice-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .top-bar > div {
        width: 100%;
        justify-content: space-between;
    }
    
    .user-info span {
        display: none; /* Hide username on very small screens */
    }
    
    .items-table th, .items-table td {
        padding: 8px;
        font-size: 13px;
    }
    
    .invoice-card {
        padding: 20px;
    }
    
    /* Make tables horizontal scroll on mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .btn {
        width: 100%; /* Full width buttons on mobile */
        margin-bottom: 8px;
    }
    
    .action-buttons .btn {
        width: auto;
        margin-bottom: 0;
    }
} 

/* Form Group Update to include select */
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    outline: none;
    background-color: #fff;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Payment Status Toggle */
.payment-toggle-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn-toggle {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-toggle:hover {
    background: #f9fafb;
}

.btn-toggle.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Table Actions & Utilities */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #4b5563;
    text-decoration: none;
    font-size: 14px;
}

.btn-icon:hover {
    background-color: #f3f4f6;
    transform: translateY(-1px);
}

.text-info {
    color: #3b82f6 !important; /* Blue-500 */
}

.text-danger {
    color: #ef4444 !important; /* Red-500 */
}

.text-info:hover {
    color: #2563eb !important; /* Blue-600 */
}
.text-danger:hover {
    color: #dc2626 !important; /* Red-600 */
}

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

.text-center {
    text-align: center !important;
}

/* Authentication Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #F3F4F6;
    padding: 20px;
}

.auth-container {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 440px;
}

.auth-container h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
    text-align: center;
}

.auth-subtitle {
    color: var(--gray);
    text-align: center;
    margin-bottom: 32px;
    font-size: 15px;
}

.auth-links {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--gray);
}

.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Auth Forms */
.auth-container input[type="text"],
.auth-container input[type="email"],
.auth-container input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
    background: #F9FAFB;
}

.auth-container input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.auth-container button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 8px;
}

.auth-container button:hover {
    background-color: var(--primary-dark);
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    z-index: 10;
}

.input-with-icon input {
    padding-left: 44px !important;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--gray);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-danger {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

@media print {
    body {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .invoice-container {
        box-shadow: none;
        border-radius: 0;
        padding: 40px;
        max-width: 100%;
    }
}
