/* Custom styles for Construction Timesheet */

/* Professional Desktop Application Styling */
.desktop-frame {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border: 2px solid #333;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    overflow: hidden;
}

.timesheet-header {
    background: #2c5aa0;
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
}

.header-left p {
    margin: 5px 0 0 0;
    opacity: 0.9;
    font-size: 16px;
}

.header-right {
    text-align: right;
}

.header-right .date {
    font-size: 24px;
    font-weight: bold;
}

.header-right .status {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    margin-top: 5px;
    display: inline-block;
}

.main-content {
    padding: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.section {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
}

.section-title {
    font-weight: 600;
    color: #2c5aa0;
    margin-bottom: 20px;
    font-size: 18px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-actions {
    background: #e7f3ff;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.basic-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    grid-template-areas: 
        "job-number date"
        "weather temperature"
        "submitted-by submitted-by";
}

/* Grid area assignments for 5 fields */
.basic-info-grid .form-group:nth-child(1) { grid-area: job-number; }
.basic-info-grid .form-group:nth-child(2) { grid-area: date; }
.basic-info-grid .form-group:nth-child(3) { grid-area: weather; }
.basic-info-grid .form-group:nth-child(4) { grid-area: temperature; }
.basic-info-grid .form-group:nth-child(5) { 
    grid-area: submitted-by;
    min-width: 250px; /* Ensure enough space for full names */
}

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

.form-label {
    font-size: 14px;
    color: #495057;
    margin-bottom: 6px;
    display: block;
    font-weight: 500;
}

.form-input, .form-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

.table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    background: #f8f9fa;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.table-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
}

.table-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    background: white;
}

.hours-input {
    width: 80px;
    text-align: center;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background: #2c5aa0;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-light {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

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

.add-row-btn {
    margin-top: 15px;
}

.section-totals {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    padding: 12px 15px;
    margin-top: 15px;
    font-weight: 600;
    color: #155724;
    text-align: right;
}

.actions-bar {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.actions-left {
    display: flex;
    gap: 15px;
}

.actions-right {
    display: flex;
    gap: 15px;
}

.notes-section {
    grid-column: 1 / -1;
}

.notes-textarea {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.icon {
    font-size: 20px;
}

.employee-section { 
    background: #fff8dc; 
}

.subcontractor-section { 
    background: #f0f8ff; 
}

.equipment-section { 
    background: #f0fff0; 
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.summary-number {
    font-size: 32px;
    font-weight: bold;
    color: #2c5aa0;
    margin-bottom: 5px;
}

.summary-label {
    color: #6c757d;
    font-size: 14px;
}

/* Theme consistency fixes */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    background-color: var(--bs-body-bg);
}

.card-header {
    background-color: var(--bs-gray-100);
    border-bottom: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
}

.card-title {
    color: var(--bs-body-color);
    font-weight: 600;
}

.card-body {
    color: var(--bs-body-color);
}

/* Dark theme specific fixes */
[data-bs-theme="dark"] .card {
    background-color: var(--bs-dark);
    border: 1px solid var(--bs-gray-700);
}

[data-bs-theme="dark"] .card-header {
    background-color: var(--bs-gray-800);
    border-bottom: 1px solid var(--bs-gray-700);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .card-title {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .card-body {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .table {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .table th {
    color: var(--bs-light);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .table td {
    border-color: var(--bs-gray-700);
}

[data-bs-theme="dark"] .text-muted {
    color: var(--bs-gray-400) !important;
}

/* Form controls dark theme */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--bs-dark);
    border-color: var(--bs-gray-600);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: var(--bs-dark);
    border-color: var(--bs-primary);
    color: var(--bs-light);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

[data-bs-theme="dark"] .form-label {
    color: var(--bs-light);
}

/* Modal dark theme */
[data-bs-theme="dark"] .modal-content {
    background-color: var(--bs-dark);
    border-color: var(--bs-gray-700);
}

[data-bs-theme="dark"] .modal-header {
    border-color: var(--bs-gray-700);
}

[data-bs-theme="dark"] .modal-footer {
    border-color: var(--bs-gray-700);
}

[data-bs-theme="dark"] .modal-title {
    color: var(--bs-light);
}

/* Badge dark theme */
[data-bs-theme="dark"] .badge.bg-secondary {
    background-color: var(--bs-gray-600) !important;
    color: var(--bs-light);
}

[data-bs-theme="dark"] .badge.bg-info {
    background-color: var(--bs-info) !important;
    color: var(--bs-light);
}

[data-bs-theme="dark"] .badge.bg-warning {
    background-color: var(--bs-warning) !important;
    color: var(--bs-dark);
}

/* Button dark theme improvements */
[data-bs-theme="dark"] .btn-outline-primary {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

[data-bs-theme="dark"] .btn-outline-primary:hover {
    background-color: var(--bs-primary);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .btn-outline-secondary {
    border-color: var(--bs-gray-600);
    color: var(--bs-gray-300);
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: var(--bs-gray-600);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .btn-outline-danger {
    border-color: var(--bs-danger);
    color: var(--bs-danger);
}

[data-bs-theme="dark"] .btn-outline-danger:hover {
    background-color: var(--bs-danger);
    color: var(--bs-light);
}

/* Ensure proper contrast for all headings */
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6 {
    color: var(--bs-light);
}

/* Custom timesheet styling dark theme compatibility */
[data-bs-theme="dark"] .desktop-frame {
    background: var(--bs-dark);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .section {
    background: var(--bs-gray-800);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .section-title {
    color: var(--bs-light);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .form-label {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .form-input,
[data-bs-theme="dark"] .form-select {
    background: var(--bs-dark);
    border-color: var(--bs-gray-600);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .form-input:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

[data-bs-theme="dark"] .table-container {
    background: var(--bs-dark);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .data-table th {
    background: var(--bs-gray-800);
    color: var(--bs-light);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .data-table td {
    color: var(--bs-light);
    border-color: var(--bs-gray-700);
}

[data-bs-theme="dark"] .data-table tbody tr:hover {
    background-color: var(--bs-gray-700);
}

[data-bs-theme="dark"] .table-input,
[data-bs-theme="dark"] .table-select {
    background: var(--bs-dark);
    border-color: var(--bs-gray-600);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .actions-bar {
    background: var(--bs-gray-800);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .notes-textarea {
    background: var(--bs-dark);
    border-color: var(--bs-gray-600);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .summary-card {
    background: var(--bs-dark);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .summary-label {
    color: var(--bs-gray-400);
}

[data-bs-theme="dark"] .quick-actions {
    background: var(--bs-gray-800);
    border-color: var(--bs-gray-600);
}

.navbar-brand {
    font-weight: 600;
}

.badge {
    font-size: 0.875em;
}

.table th {
    font-weight: 600;
    border-bottom: 2px solid var(--bs-border-color);
}

.btn-outline-danger:hover {
    color: var(--bs-white);
}

.input-group .btn {
    z-index: 1;
}

.weather-card {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
}

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

.stats-card {
    transition: transform 0.2s;
}

.stats-card:hover {
    transform: translateY(-2px);
}

.text-muted {
    color: var(--bs-secondary) !important;
}

/* Real-time Search functionality styles */
select[data-searchable] {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

select[data-searchable]:hover {
    border-color: #2c5aa0;
    box-shadow: 0 0 3px rgba(44, 90, 160, 0.2);
}

select[data-searchable]:focus {
    outline: 2px solid #2c5aa0;
    outline-offset: 2px;
    border-color: #2c5aa0;
    box-shadow: 0 0 5px rgba(44, 90, 160, 0.3);
}

.search-indicator {
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666;
    font-size: 12px;
    opacity: 0.7;
    transition: all 0.2s ease;
    font-weight: bold;
}

select[data-searchable]:hover + .search-indicator,
select[data-searchable]:focus + .search-indicator {
    opacity: 1;
}

/* Active search state */
select[data-searchable].searching {
    border-color: #2c5aa0;
    box-shadow: 0 0 8px rgba(44, 90, 160, 0.4);
    background: linear-gradient(90deg, #f8f9fa 0%, #e7f3ff 100%);
}

/* Search results indicator */
.search-indicator.active {
    color: #2c5aa0;
    opacity: 1;
    animation: searchPulse 0.3s ease-in-out;
}

@keyframes searchPulse {
    0% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.1); }
    100% { transform: translateY(-50%) scale(1); }
}

.alert {
    border: none;
    border-radius: 0.5rem;
}

.modal-header {
    border-bottom: 1px solid var(--bs-border-color);
}

.modal-footer {
    border-top: 1px solid var(--bs-border-color);
}

.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
}

.container {
    max-width: 1200px;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
    /* Header responsive */
    .timesheet-header {
        flex-direction: column;
        text-align: center;
        padding: 15px 20px;
    }
    
    .header-left h1 {
        font-size: 22px;
        margin-bottom: 5px;
    }
    
    .header-right {
        text-align: center;
        margin-top: 10px;
    }
    
    .header-right .date {
        font-size: 20px;
    }
    
    /* Main content adjustments */
    .main-content {
        padding: 15px;
    }
    
    .desktop-frame {
        margin: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    
    /* Grid layouts to single column */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-bottom: 20px;
    }
    
    .basic-info-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        grid-template-areas: 
            "job-number"
            "date"
            "weather"
            "temperature"
            "submitted-by";
    }
    
    .basic-info-grid .form-group:nth-child(5) {
        min-width: auto; /* Remove min-width constraint on mobile */
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Section adjustments */
    .section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .section-title {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    /* Table responsive - convert to cards */
    .table-container {
        overflow-x: auto;
    }
    
    .data-table {
        font-size: 12px;
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }
    
    /* Mobile-friendly input sizing */
    .form-input, .form-select {
        padding: 10px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .table-input, .table-select {
        padding: 6px;
        font-size: 12px;
    }
    
    .hours-input {
        width: 60px;
        font-size: 12px;
    }
    
    /* Actions bar mobile */
    .actions-bar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .actions-left,
    .actions-right {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    /* Quick actions mobile */
    .quick-actions {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    
    /* Container adjustments */
    .container {
        padding: 0 1rem;
    }
    
    /* Card mobile adjustments */
    .card {
        margin-bottom: 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Notes textarea mobile */
    .notes-textarea {
        min-height: 100px;
        padding: 12px;
        font-size: 16px;
    }
    
    /* Navigation mobile improvements */
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 14px;
    }
    
    .dropdown-menu {
        font-size: 14px;
    }
    
    /* Modal mobile */
    .modal-dialog {
        margin: 10px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    /* Summary cards mobile */
    .summary-card {
        padding: 15px;
    }
    
    .summary-number {
        font-size: 24px;
    }
    
    .summary-label {
        font-size: 12px;
    }
    
    /* Employee/Equipment/Subcontractor rows mobile */
    .employee-row,
    .equipment-row,
    .subcontractor-row {
        padding: 0.75rem;
    }
}

/* Smaller mobile devices */
@media (max-width: 480px) {
    .header-left h1 {
        font-size: 20px;
    }
    
    .header-right .date {
        font-size: 18px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .section {
        padding: 12px;
    }
    
    .data-table {
        font-size: 11px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .form-input, .form-select {
        padding: 8px;
    }
    
    .actions-left,
    .actions-right {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .container {
        padding: 0 0.5rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .form-input, .form-select {
        min-height: 44px;
        padding: 12px;
    }
    
    .table-input, .table-select {
        min-height: 36px;
        padding: 8px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .dropdown-item {
        min-height: 44px;
        padding: 12px 16px;
        display: flex;
        align-items: center;
    }
}

/* Dark mode enhancements */
[data-bs-theme="dark"] .employee-row,
[data-bs-theme="dark"] .equipment-row,
[data-bs-theme="dark"] .subcontractor-row {
    background-color: var(--bs-gray-800);
    border-color: var(--bs-gray-600);
}

[data-bs-theme="dark"] .employee-row:hover,
[data-bs-theme="dark"] .equipment-row:hover,
[data-bs-theme="dark"] .subcontractor-row:hover {
    background-color: var(--bs-gray-700);
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "";
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--bs-primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Consistent Remove Button Styling */
.btn-remove {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

.btn-remove:active {
    transform: scale(0.95);
}

.btn-remove i {
    font-size: 12px;
}

/* Dark mode support for remove button */
[data-bs-theme="dark"] .btn-remove {
    background-color: #dc3545;
    color: white;
}

[data-bs-theme="dark"] .btn-remove:hover {
    background-color: #e04555;
}

/* Reports dropdown menu alignment fix */
.navbar .dropdown-menu {
    min-width: 220px;
}

.navbar .dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
}

.navbar .dropdown-menu .dropdown-item i {
    width: 24px;
    text-align: center;
}

/* Fix table header contrast on reports */
.table-success th,
.table-success td {
    color: #1a1a1a !important;
}

.table thead.table-success th {
    color: #1a1a1a !important;
    font-weight: 600;
}

/* Fix table-secondary header contrast in dark theme */
.table-dark thead.table-secondary th,
.table thead.table-secondary th {
    background-color: #495057 !important;
    color: #ffffff !important;
    font-weight: 600;
    border-color: #6c757d !important;
}

/* Fix table-primary header contrast */
.table-dark thead.table-primary th,
.table thead.table-primary th {
    background-color: #0d6efd !important;
    color: #ffffff !important;
    font-weight: 600;
    border-color: #0d6efd !important;
}

/* Fix nested breakdown table header styling */
.table-dark .table thead th,
.breakdown-table thead th {
    background-color: #495057 !important;
    color: #ffffff !important;
    font-weight: 600;
}

/* Better header styling for report tables */
.report-table thead th {
    background-color: #0d6efd !important;
    color: white !important;
    border-color: #0d6efd !important;
}

/* Improved dropdown styling in dark theme */
.form-select option {
    background-color: #212529;
    color: #ffffff;
}

.form-select optgroup {
    background-color: #343a40;
    color: #ffffff;
    font-weight: 600;
}
