/* Modern UI Reset & Global Styles */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

:root {
    /* Modern Color Palette */
    --primary: #4361ee;
    --primary-light: #4895ef;
    --secondary: #3a0ca3;
    --success: #2ec4b6;
    --warning: #ff9f1c;
    --danger: #e71d36;
    --dark: #1a1a2e;
    --gray-dark: #4a4e69;
    --gray: #9a8c98;
    --gray-light: #c9ada7;
    --light: #f8f9fa;
    --white: #ffffff;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 3rem;
}

body { 
    background-color: #f5f7fa; 
    color: var(--dark); 
    line-height: 1.6;
    overflow-x: hidden;
}

.container { 
    max-width: 1280px; 
    margin: 0 auto; 
    padding: var(--space-lg);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-md);
    color: var(--dark);
}

h1 {
    font-size: 1.8rem;
    margin-bottom: var(--space-lg);
    position: relative;
    padding-bottom: var(--space-sm);
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background-color: var(--primary);
    border-radius: var(--radius-sm);
}

h2 {
    font-size: 1.5rem;
    margin-top: var(--space-lg);
}

h3 {
    font-size: 1.25rem;
}

a { 
    color: var(--primary); 
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover { 
    color: var(--primary-light); 
}

hr {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.05);
    margin: var(--space-xl) 0;
}

/* Modern Navigation */
nav { 
    background-color: var(--white); 
    padding: var(--space-md) var(--space-xl); 
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

nav .logo { 
    font-size: 1.5rem; 
    font-weight: 700; 
    color: var(--primary);
    display: flex;
    align-items: center;
}

nav .logo::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: var(--primary);
    margin-right: var(--space-sm);
    border-radius: 50%;
}

nav ul { 
    list-style: none; 
    display: flex; 
    gap: var(--space-lg); 
}

nav ul a { 
    font-weight: 500; 
    color: var(--gray-dark); 
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    position: relative;
}

nav ul a:hover { 
    color: var(--primary); 
    background-color: rgba(67, 97, 238, 0.05);
}

nav ul a::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: var(--primary);
    transition: all 0.2s ease;
    transform: translateX(-50%);
}

nav ul a:hover::after {
    width: 80%;
}

/* Common Form Elements */
form { 
    display: flex; 
    flex-direction: column; 
    gap: var(--space-md); 
    background: var(--white); 
    padding: var(--space-xl); 
    border-radius: var(--radius-md); 
    box-shadow: var(--shadow-sm); 
    margin-bottom: var(--space-lg); 
}

form label {
    font-weight: 500;
    margin-bottom: var(--space-xs);
    display: block;
}

input, select, textarea, button { 
    padding: var(--space-md); 
    border: 1px solid rgba(0,0,0,0.1); 
    border-radius: var(--radius-sm); 
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus { 
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

button { 
    background-color: var(--primary); 
    color: var(--white); 
    border: none; 
    cursor: pointer; 
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

button:hover { 
    background-color: var(--primary-light); 
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

button:active {
    transform: translateY(0);
}

/* Common Button Styles */
.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.85rem;
}

.btn-secondary { background-color: var(--secondary); }
.btn-success { background-color: var(--success); }
.btn-warning { background-color: var(--warning); color: var(--dark); }
.btn-danger { background-color: var(--danger); }

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

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--white);
    margin: 5% auto;
    padding: var(--space-xl);
    border: none;
    width: 90%;
    max-width: 550px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
    position: relative;
}

.close-btn {
    color: var(--gray);
    position: absolute;
    right: var(--space-lg);
    top: var(--space-lg);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    color: var(--danger);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Status Indicators */
.status-active { background-color: var(--success); }
.status-inactive { background-color: var(--warning); color: var(--dark); }
.status-closed, .status-draft { background-color: var(--gray); }
.status-sent { background-color: var(--secondary); }
.status-paid { background-color: var(--success); }

/* Card Styles */
.card {
    background-color: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-lg) 0;
    background-color: var(--white);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-md);
    overflow: hidden;
}

table th, table td {
    padding: var(--space-md);
    text-align: left;
}

table th {
    background-color: rgba(0,0,0,0.02);
    font-weight: 600;
    color: var(--gray-dark);
    border-bottom: 2px solid rgba(0,0,0,0.05);
}

table tbody tr {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

table tbody tr:hover {
    background-color: rgba(0,0,0,0.01);
}

/* Loading Skeleton Animation */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.06) 25%,
        rgba(0, 0, 0, 0.04) 50%,
        rgba(0, 0, 0, 0.06) 75%
    );
    background-size: 200% 100%;
    animation: pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
    height: 1em;
    margin-bottom: var(--space-sm);
}

@keyframes pulse {
    0% { background-position: 0% 0%; }
    100% { background-position: -135% 0%; }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .container { 
        max-width: 100%; 
        padding: var(--space-lg);
    }
    
    /* Adjust grid layouts for tablets */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 992px) {
    /* Tablet adjustments */
    .container { 
        padding: var(--space-md); 
    }
    
    /* Navigation improvements */
    nav {
        padding: var(--space-sm) var(--space-md);
    }
    
    nav ul {
        gap: var(--space-xs);
    }
    
    nav ul li a {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.85rem;
    }
    
    nav ul li a i {
        font-size: 1rem;
    }
    
    /* Hide text on smaller tablets, show only icons */
    nav ul li a span {
        display: none;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
}

@media (max-width: 768px) {
    /* Mobile styles */
    .container { 
        padding: var(--space-sm); 
    }
    
    /* Mobile navigation */
    nav {
        padding: var(--space-sm);
        flex-direction: row;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    nav .logo {
        font-size: 1.1rem;
    }
    
    nav ul {
        width: auto;
        gap: var(--space-xs);
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    nav ul::-webkit-scrollbar {
        display: none;
    }
    
    nav ul li a {
        padding: var(--space-xs);
        min-width: 40px;
        justify-content: center;
    }
    
    /* Single column layouts */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
    }
    
    /* Tables responsive */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    /* Cards stack on mobile */
    .grid-container {
        grid-template-columns: 1fr !important;
    }
    
    /* Buttons full width on mobile */
    button,
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95% !important;
        max-width: none;
        margin: var(--space-sm);
        padding: var(--space-md);
    }
    
    /* Form adjustments */
    .form-section {
        grid-template-columns: 1fr !important;
    }
    
    h1 {
        font-size: 1.25rem;
    }
    
    h2 {
        font-size: 1.1rem;
    }
    
    h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    /* Extra small mobile */
    nav .logo {
        font-size: 1rem;
    }
    
    .container {
        padding: var(--space-xs);
    }
    
    nav ul li a i {
        font-size: 0.9rem;
    }
    
    /* Compact theme toggle */
    .theme-toggle {
        transform: scale(0.85);
    }
}

/* Touch-friendly improvements for all devices */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button,
    .btn,
    nav ul li a,
    input,
    select,
    textarea {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    *:hover {
        transform: none !important;
    }
    
    /* Better tap feedback */
    button:active,
    .btn:active,
    nav ul li a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Print styles */
@media print {
    nav,
    .theme-toggle,
    button,
    .btn {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    * {
        box-shadow: none !important;
    }
}