/* Work Tracking System - Styles */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--gray-900);
    color: white;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-700);
    margin-bottom: 1rem;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--gray-300);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--gray-700);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-700);
}

.user-info {
    font-size: 0.875rem;
    color: var(--gray-300);
    margin-bottom: 0.5rem;
}

.user-role {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--primary);
    border-radius: 9999px;
    font-size: 0.75rem;
    text-transform: capitalize;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.header {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-100);
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--gray-900);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

select.form-control {
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn i {
    margin-right: 0.5rem;
}

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

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

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

.btn-success:hover {
    background: #059669;
}

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

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-value.text-success { color: var(--success); }
.stat-value.text-warning { color: var(--warning); }
.stat-value.text-danger { color: var(--danger); }
.stat-value.text-primary { color: var(--primary); }

/* Tables */
.table-container {
    overflow-x: auto;
}

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

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
}

tr:hover {
    background: var(--gray-50);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }
.badge-info { background: #e0f2fe; color: #0369a1; }

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal.modal-wide {
    max-width: 800px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filters .form-control {
    width: auto;
    min-width: 150px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 0.375rem;
    cursor: pointer;
}

.pagination button:hover {
    background: var(--gray-50);
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--gray-500);
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ===================== Calendar ===================== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--gray-200);
}

.calendar-grid--header {
    background: transparent;
    gap: 1px;
    margin-bottom: 1px;
}

.calendar-day-header {
    background: var(--gray-100);
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    padding: 4px 0;
    text-transform: uppercase;
}

.calendar-day {
    background: white;
    min-height: 90px;
    padding: 5px 6px;
    vertical-align: top;
    overflow: hidden;
}

.calendar-day--today {
    background: #eff6ff;
}

.calendar-day--other-month {
    background: var(--gray-50);
    min-height: 90px;
}

.calendar-day-number {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 3px;
}

.calendar-day--today .calendar-day-number {
    color: var(--primary);
    font-weight: 700;
}

.calendar-chip {
    font-size: 0.70rem;
    padding: 2px 5px;
    border-radius: 3px;
    margin-bottom: 2px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    line-height: 1.4;
}

.calendar-chip:hover {
    filter: brightness(0.92);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -250px;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filters {
        flex-direction: column;
    }

    .filters .form-control {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    /* Hide non-printable elements */
    .sidebar,
    .header,
    .no-print,
    .filters,
    .nav-item,
    .btn {
        display: none !important;
    }

    /* Reset layout for print */
    .app-container {
        display: block;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .content {
        padding: 0;
    }

    /* Card styling for print */
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }

    .card-header {
        background: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Table styling for print */
    table {
        font-size: 10pt;
    }

    th, td {
        padding: 4px 8px;
    }

    /* Ensure colors print */
    .badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Page breaks */
    .card {
        page-break-after: auto;
    }

    /* Show full URLs for links */
    a[href^="http"]:after {
        content: none;
    }
}

/* Job links in time entries */
.job-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.job-link:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

/* Multi-select dropdown */
.multi-select {
    position: relative;
    min-width: 150px;
}

.multi-select-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.multi-select-display:hover {
    border-color: var(--gray-500);
}

.multi-select-display i {
    font-size: 0.75rem;
    color: var(--gray-500);
    transition: transform 0.2s;
}

.multi-select.open .multi-select-display i {
    transform: rotate(180deg);
}

.multi-select-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.25rem;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
}

.multi-select.open .multi-select-dropdown {
    display: block;
}

.multi-select-dropdown label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.15s;
}

.multi-select-dropdown label:hover {
    background: var(--gray-100);
}

.multi-select-dropdown input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}
