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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f7fafc;
    color: #2d3748;
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.company-logo {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.logo-placeholder {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #4a5568;
    color: white;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.875rem;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: #2d3748;
    font-weight: 600;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #4a5568;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover {
    background: #edf2f7;
    color: #2d3748;
}

.nav-link.active {
    background: #4299e1;
    color: white;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header Section */
.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.week-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.week-selector label {
    font-weight: 600;
    color: #2d3748;
}

.week-selector select {
    padding: 0.5rem 1rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

/* Buttons */
.btn-primary {
    padding: 0.75rem 1.5rem;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #3182ce;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
}

.btn-import {
    padding: 0.75rem 1.5rem;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-import:hover {
    background: #38a169;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: #e2e8f0;
    color: #2d3748;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Stats Banner */
.stats-banner {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-box {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Filter Section */
.filter-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filter-header h3 {
    font-size: 1.25rem;
    color: #2d3748;
    margin: 0;
}

.filter-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #e2e8f0;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.875rem;
}

.filter-input,
.filter-select {
    padding: 0.6rem;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
    transition: all 0.2s;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.filter-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-count {
    color: #4a5568;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    background: #edf2f7;
    border-radius: 6px;
}

@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .filter-actions button {
        width: 100%;
    }
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-edit {
    padding: 0.5rem 1rem;
    background: white;
    color: #4299e1;
    border: 1px solid #4299e1;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: #4299e1;
    color: white;
}

/* Payroll Card */
.payroll-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 2rem;
}

.payroll-card h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.date-range {
    color: #718096;
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Table */
.table-container {
    overflow-x: auto;
    max-height: 70vh;
    position: relative;
}

.payroll-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.payroll-table thead {
    background: #4a5568;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.payroll-table th {
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid #cbd5e0;
}

.payroll-table th.employee-col {
    text-align: left;
    min-width: 200px;
}

.payroll-table th.total-col {
    background: #edf2f7;
    color: #2d3748;
}

.payroll-table th .date {
    font-size: 0.75rem;
    font-weight: normal;
    display: block;
    margin-top: 0.25rem;
}

.payroll-table td {
    padding: 1rem;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.payroll-table td.employee-name {
    text-align: left;
    font-weight: 600;
    color: #2d3748;
}

.payroll-table td.total-cell {
    background: #edf2f7;
    font-weight: 700;
    color: #2d3748;
}

.payroll-table td.has-value {
    background: #f0fff4;
    font-weight: 600;
}

.payroll-table td.has-corrected {
    background: #e6f2ff;
    font-weight: 700;
    color: #2563eb;
    border: 2px solid #93c5fd;
    cursor: pointer;
    position: relative;
}

.payroll-table td.has-corrected:hover {
    background: #dbeafe;
}

.correction-indicator {
    color: #2563eb;
    margin-left: 4px;
}

.payroll-table td.has-error {
    background: #fff5f5;
    color: #c53030;
    font-weight: 700;
    border: 2px solid #fc8181;
    cursor: pointer;
    position: relative;
}

.payroll-table td.has-error .error-indicator {
    color: #e53e3e;
    font-weight: bold;
    margin-left: 4px;
}

/* Cell Editor */
.cell-editor {
    padding: 8px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 120px;
}

.value-select {
    width: 100%;
    padding: 6px;
    border: 2px solid #4299e1;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    background: white;
}

.note-input {
    width: 100%;
    padding: 6px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 0.875rem;
}

.editor-buttons {
    display: flex;
    gap: 4px;
    justify-content: space-between;
}

.btn-save-cell,
.btn-cancel-cell,
.btn-reset-cell {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-save-cell {
    background: #48bb78;
    color: white;
}

.btn-save-cell:hover {
    background: #38a169;
}

.btn-reset-cell {
    background: #ed8936;
    color: white;
}

.btn-reset-cell:hover {
    background: #dd6b20;
}

.btn-cancel-cell {
    background: #e2e8f0;
    color: #2d3748;
}

.btn-cancel-cell:hover {
    background: #cbd5e0;
}

.payroll-table tbody tr.has-errors {
    background: #fffaf0;
}

.payroll-table tbody tr.has-errors:hover {
    background: #fef5e7;
}

.payroll-table tbody tr:hover {
    background: #f7fafc;
}

.warning-icon {
    color: #f59e0b;
    font-size: 1rem;
    cursor: help;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    border: 3px solid #e2e8f0;
    border-top: 3px solid #4299e1;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No Data */
.no-data {
    text-align: center;
    padding: 3rem;
    color: #718096;
}

.no-data .hint {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Users Grid */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.user-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: all 0.2s;
}

.user-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.user-card.inactive {
    opacity: 0.6;
}

.user-card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-card-header h3 {
    font-size: 1.25rem;
    color: #2d3748;
    margin: 0;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-active {
    background: #c6f6d5;
    color: #22543d;
}

.badge-inactive {
    background: #fed7d7;
    color: #742a2a;
}

.user-card-body {
    padding: 1.5rem;
}

.user-notes {
    color: #4a5568;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.user-notes-empty {
    color: #a0aec0;
    font-style: italic;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.user-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat {
    text-align: center;
}

.stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: #718096;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.stat .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
}

.user-card-footer {
    padding: 1rem 1.5rem;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
    text-align: right;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.event-details-content {
    max-width: 700px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #2d3748;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #718096;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.close-btn:hover {
    color: #2d3748;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Form */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2d3748;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.form-control[readonly] {
    background: #f7fafc;
    color: #718096;
}

textarea.form-control {
    resize: vertical;
}

/* Stats Grid in Modal */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
    margin-top: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-item .stat-label {
    display: block;
    font-size: 0.75rem;
    color: #718096;
    margin-bottom: 0.25rem;
}

.stat-item .stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #2d3748;
}

/* Event Details Modal */
.event-summary {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Correction Section in Modal */
.correction-section {
    background: #fffaf0;
    border: 2px solid #fbd38d;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.correction-section h4 {
    margin: 0 0 1rem 0;
    color: #744210;
    font-size: 1rem;
}

.correction-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row label {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}

.correction-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-save-correction {
    flex: 1;
    padding: 0.75rem;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-save-correction:hover {
    background: #38a169;
    transform: translateY(-1px);
}

.btn-reset-correction {
    padding: 0.75rem 1rem;
    background: #ed8936;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset-correction:hover {
    background: #dd6b20;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.summary-item.error {
    color: #c53030;
    font-weight: 600;
}

.summary-item .label {
    font-weight: 600;
    color: #4a5568;
}

.summary-item .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
}

.events-timeline {
    margin-top: 1rem;
}

.events-timeline h4 {
    margin-bottom: 1rem;
    color: #2d3748;
    font-size: 1.1rem;
}

.event-item {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.event-item:last-child {
    margin-bottom: 0;
}

.event-header {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: #2d3748;
}

.event-details {
    padding-left: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.8;
}

.event-details div {
    margin-bottom: 0.5rem;
}

.event-details strong {
    color: #4a5568;
    min-width: 100px;
    display: inline-block;
}

.event-meta {
    color: #718096;
    font-size: 0.85rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.no-events {
    text-align: center;
    padding: 2rem;
    color: #718096;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .header-section {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .header-actions button,
    .header-actions a {
        width: 100%;
    }
    
    .stats-banner {
        flex-direction: column;
    }
    
    .stat-box {
        padding: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }

    .week-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .week-selector select {
        width: 100%;
    }

    .users-grid {
        grid-template-columns: 1fr;
    }

    .payroll-table {
        font-size: 0.875rem;
    }

    .payroll-table th,
    .payroll-table td {
        padding: 0.5rem;
    }
}
