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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #1a202c;
    color: #e2e8f0;
    line-height: 1.6;
}

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

.app-header {
    background: #2d3748;
    border-bottom: 1px solid #4a5568;
    padding: 1rem 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    margin: 0 auto;
}

.header-content h1 {
    color: #f7fafc;
    font-size: 1.8rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    color: #cbd5e0;
    font-size: 0.9rem;
}

/* Tab Navigation */
.tab-navigation {
    background: #374151;
    border-bottom: 1px solid #4a5568;
    padding: 0 2rem;
    display: flex;
    align-items: center;
}

.tab-button {
    background: none;
    border: none;
    color: #9ca3af;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.tab-button:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.05);
}

.tab-button.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Cards */
.card {
    background: #2d3748;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
    border: 1px solid #4a5568;
    overflow: hidden;
}

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #4a5568;
    background: #374151;
}

.card-header h2 {
    color: #f7fafc;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 2rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #cbd5e0;
    font-weight: 500;
    font-size: 0.9rem;
}

input, select, textarea, button {
    font-family: inherit;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #4a5568;
    border-radius: 6px;
    background: #374151;
    color: #e2e8f0;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

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

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

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

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

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

button:disabled {
    background: #6b7280;
    cursor: not-allowed;
    transform: none;
}

/* Location Controls */
.location-controls {
    display: flex;
    align-items: end;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.location-controls .form-group {
    margin-bottom: 0;
    min-width: 200px;
}

.connection-status {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.connected {
    background: #064e3b;
    border: 1px solid #10b981;
    color: #6ee7b7;
}

.disconnected {
    background: #7f1d1d;
    border: 1px solid #ef4444;
    color: #fecaca;
}

/* Rota Table */
.rota-container {
    min-height: 500px;
}

.week-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.week-selector input {
    width: auto;
    min-width: 150px;
}

.table-container {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.rota-table, .backups-table, .locations-table {
    width: 100%;
    border-collapse: collapse;
    background: #374151;
    border-radius: 8px;
    overflow: hidden;
}

.rota-table th, .backups-table th, .locations-table th {
    background: #4a5568;
    padding: 1rem 0.5rem;
    text-align: center;
    border-right: 1px solid #6b7280;
    font-weight: 600;
    color: #f7fafc;
    font-size: 0.85rem;
}

.rota-table td, .backups-table td, .locations-table td {
    padding: 0.75rem 0.5rem;
    border-right: 1px solid #6b7280;
    border-bottom: 1px solid #6b7280;
    text-align: center;
    vertical-align: middle;
    font-size: 0.85rem;
}

.staff-name {
    font-weight: bold;
    color: #cbd5e0;
    text-align: left !important;
    padding-left: 1rem !important;
}

.time-inputs {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
    align-items: center;
}

.time-input {
    width: 60px;
    padding: 0.3rem;
    border: 1px solid #4a5568;
    border-radius: 4px;
    background: #374151;
    color: #e2e8f0;
    text-align: center;
    font-size: 0.8rem;
}

.time-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.hours-display {
    font-weight: bold;
    color: #10b981;
}

.rota-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.staff-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.push-btn {
    font-weight: bold;
    font-size: 1rem;
    padding: 1rem 2rem;
}

/* Backups Section */
.backup-filters {
    display: flex;
    align-items: end;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.backup-filters .form-group {
    margin-bottom: 0;
    min-width: 200px;
}

.backup-stats {
    display: flex;
    gap: 2rem;
    padding: 1.5rem;
    background: #374151;
    border-radius: 8px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #60a5fa;
}

/* Automation Section */
.automation-status {
    display: flex;
    gap: 2rem;
    padding: 1.5rem;
    background: #374151;
    border-radius: 8px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.automation-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.location-control-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border: 1px solid #4a5568;
    border-radius: 6px;
    margin-bottom: 1rem;
    background: #374151;
}

.location-control-info {
    flex: 1;
}

.location-control-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.automation-toggle {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.automation-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.automation-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4a5568;
    transition: .4s;
    border-radius: 34px;
}

.automation-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .automation-slider {
    background-color: #10b981;
}

input:checked + .automation-slider:before {
    transform: translateX(26px);
}

/* Settings Section */
.settings-actions {
    margin-bottom: 2rem;
}

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

.pagination [role="status"] {
    width: 100%;
    text-align: center;
    color: #9ca3af;
}

.pagination button {
    padding: 0.5rem 1rem;
    background: #374151;
    border: 1px solid #4a5568;
    color: #e2e8f0;
    border-radius: 4px;
}

.pagination button:hover {
    background: #4a5568;
}

.pagination button.active {
    background: #3b82f6;
    border-color: #3b82f6;
}

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #2d3748;
    border-radius: 12px;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #4a5568;
}

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

.modal-title {
    color: #f7fafc;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: #374151;
    color: #f7fafc;
}

.modal-body {
    padding: 2rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-weight: 500;
}

.alert-success {
    background: #064e3b;
    border: 1px solid #10b981;
    color: #6ee7b7;
}

.alert-error {
    background: #7f1d1d;
    border: 1px solid #ef4444;
    color: #fecaca;
}

.alert-info {
    background: #1e3a8a;
    border: 1px solid #3b82f6;
    color: #93c5fd;
}

.alert-warning {
    background: #78350f;
    border: 1px solid #f59e0b;
    color: #fbbf24;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #9ca3af;
    font-size: 1.1rem;
}

/* Progress Bar */
.push-status {
    margin-top: 1.5rem;
    padding: 1.5rem;
    border-radius: 8px;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #374151;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: #10b981;
    width: 0%;
    transition: width 0.3s ease;
}

/* Push Date Range: persistent status bar */
.push-range-status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #2d3748;
    border-bottom: 1px solid #4a5568;
    padding: 0.75rem 2rem;
    font-size: 0.85rem;
    color: #cbd5e0;
}

.push-range-status-bar__text {
    white-space: nowrap;
}

.push-range-status-bar__bar {
    flex: 1;
    margin: 0;
}

.push-range-status-bar .modal-close {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

/* Push Date Range: per-week progress rows */
.push-range-week-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.5rem 0;
    max-height: 320px;
    overflow-y: auto;
}

.push-range-week-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid #4a5568;
    font-size: 0.85rem;
}

.push-range-week-row__label {
    font-weight: 500;
    color: #f7fafc;
    white-space: nowrap;
}

.push-range-week-row__status {
    color: #cbd5e0;
    text-align: right;
}

.push-range-week-row--success {
    background: #064e3b;
    border-color: #10b981;
}

.push-range-week-row--success .push-range-week-row__status {
    color: #6ee7b7;
}

.push-range-week-row--error {
    background: #7f1d1d;
    border-color: #ef4444;
}

.push-range-week-row--error .push-range-week-row__status {
    color: #fecaca;
}

.push-range-week-row--active {
    background: #1e3a8a;
    border-color: #3b82f6;
}

.push-range-week-row--active .push-range-week-row__status {
    color: #93c5fd;
}

.push-range-week-row--pending {
    background: #2d3748;
}

.push-range-week-row--pending .push-range-week-row__status {
    color: #9ca3af;
}

.push-range-week-row--skipped {
    background: #2d3748;
    border-style: dashed;
}

.push-range-week-row--skipped .push-range-week-row__status {
    color: #9ca3af;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .header-controls {
        justify-content: space-between;
    }

    .tab-navigation {
        padding: 0 1rem;
        overflow-x: auto;
        white-space: nowrap;
    }

    .push-range-status-bar {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
    }

    .push-range-status-bar__bar {
        order: 3;
        flex-basis: 100%;
    }

    .main-content {
        padding: 1rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    .location-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .location-controls .form-group {
        min-width: auto;
    }

    .week-selector {
        flex-direction: column;
        gap: 0.5rem;
    }

    .rota-actions {
        flex-direction: column;
    }

    .backup-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .backup-filters .form-group {
        min-width: auto;
    }

    .backup-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .modal-body {
        padding: 1.5rem;
    }

    .modal-actions {
        justify-content: stretch;
        flex-direction: column;
    }

    .table-container {
        font-size: 0.8rem;
    }

    .time-input {
        width: 50px;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .rota-table th,
    .rota-table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }

    .time-inputs {
        flex-direction: column;
        gap: 0.2rem;
    }

    .time-input {
        width: 45px;
    }

    .staff-actions {
        flex-direction: column;
        gap: 0.25rem;
    }

    .btn-small {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }
}
