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

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

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Page Management */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* Landing Page */
#landing-page h1 {
    text-align: center;
    font-size: 2rem;
    margin: 40px 0;
    color: #2c3e50;
}

.button-grid {
    display: grid;
    gap: 20px;
    margin-top: 40px;
}

@media (min-width: 768px) {
    .button-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Big Buttons for Landing */
.big-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 40px 20px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.big-button:active {
    transform: scale(0.98);
}

.big-button:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Header Bar */
.header-bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.header-bar h2 {
    flex: 1;
    font-size: 1.5rem;
    color: #2c3e50;
    min-width: 200px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    .header-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .header-bar h2 {
        text-align: center;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions button {
        flex: 1;
    }
}

/* Back Button */
.back-button {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 48px;
}

.back-button:active {
    background-color: #5a6268;
}

/* Action Buttons */
.action-button {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 48px;
    width: 100%;
    margin-bottom: 10px;
}

.action-button:active {
    background-color: #218838;
}

@media (min-width: 768px) {
    .action-button {
        width: auto;
        margin-bottom: 0;
    }
}

.secondary-button {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 15px 30px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 48px;
    width: 100%;
}

.secondary-button:active {
    background-color: #5a6268;
}

@media (min-width: 768px) {
    .secondary-button {
        width: auto;
    }
}

/* Table Controls */
.table-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .table-controls {
        flex-direction: row;
        align-items: center;
    }
}

/* CSV Controls */
.csv-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .csv-controls {
        flex-direction: row;
        gap: 10px;
    }
}

.timestamp {
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(to right,
        #ef5350 0%,
        #ffb74d 50%,
        #66bb6a 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --progress: 100%;
}

.timestamp::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 0;
    transition: transform 0.5s ease;
    transform: translateX(calc(-100% + var(--progress)));
}

.timestamp span {
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 0 20px 0 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
}

@media (max-width: 767px) {
    table {
        font-size: 0.85rem;
    }
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
}

th:last-child, td:last-child {
    border-right: none;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
}

th:hover {
    background-color: #e9ecef;
}

.sort-indicator {
    margin-left: 5px;
    font-size: 0.8rem;
    color: #6c757d;
}

th.sorted-asc .sort-indicator::after {
    content: '▲';
}

th.sorted-desc .sort-indicator::after {
    content: '▼';
}

/* Alternating row colors */
tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

tbody tr:nth-child(even) {
    background-color: #e3f2fd;
}

tbody tr:hover {
    background-color: #fff9e6 !important;
}


/* Forms */
.search-form, .computer-form {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
}

.form-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    min-height: 48px;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

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

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

@media (min-width: 768px) {
    .form-actions {
        flex-direction: row;
    }
}

/* Search Results */
.search-results {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-result-item {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 4px;
    margin-bottom: 10px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #fff9e6;
}

.search-result-item:active {
    background-color: #ffe4b3;
}

.search-result-item strong {
    color: #2c3e50;
}

.search-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.confirmed-badge {
    background-color: #4caf50;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 1.1rem;
}

/* Detail View */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 15px;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s;
}

.detail-header.confirmed {
    background-color: #4caf50;
}

.detail-header.confirmed h2,
.detail-header.confirmed .progress-counter {
    color: white;
}

.back-to-spreadsheet {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 48px;
    white-space: nowrap;
}

.back-to-spreadsheet:active {
    background-color: #5a6268;
}

.detail-header.confirmed .back-to-spreadsheet {
    background-color: #2e7d32;
}

.detail-header.confirmed .back-to-spreadsheet:active {
    background-color: #1b5e20;
}

.progress-info {
    flex: 1;
    text-align: center;
}

.progress-info h2 {
    font-size: 1.3rem;
    margin-bottom: 5px;
    color: #2c3e50;
}

.progress-counter {
    font-size: 1rem;
    color: #6c757d;
    font-weight: 600;
}

.filter-toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.filter-label {
    font-size: 0.85rem;
    color: #6c757d;
    font-weight: 600;
    transition: color 0.3s;
}

.filter-label.active {
    color: #2c3e50;
}

.detail-header.confirmed .filter-label {
    color: rgba(255, 255, 255, 0.6);
}

.detail-header.confirmed .filter-label.active {
    color: white;
}

.filter-toggle {
    position: relative;
    width: 50px;
    height: 26px;
    background-color: #667eea;
    border: none;
    border-radius: 13px;
    cursor: pointer;
    transition: background-color 0.3s;
    padding: 0;
}

.filter-toggle:active {
    transform: scale(0.98);
}

.filter-toggle.active {
    background-color: #ff8c42;
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filter-toggle.active .toggle-slider {
    transform: translateX(24px);
}

.detail-header.confirmed .filter-toggle {
    background-color: #2e7d32;
}

.detail-header.confirmed .filter-toggle.active {
    background-color: #ff8c42;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.nav-arrow {
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-arrow:active {
    background-color: #5568d3;
}

.nav-arrow:disabled {
    background-color: #dee2e6;
    cursor: not-allowed;
}

.detail-header.confirmed .nav-arrow {
    background-color: #2e7d32;
}

.detail-header.confirmed .nav-arrow:active {
    background-color: #1b5e20;
}

.detail-header.confirmed .nav-arrow:disabled {
    background-color: rgba(255, 255, 255, 0.3);
}

.detail-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.detail-card {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.detail-card label {
    display: block;
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 600;
}

.detail-value {
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 500;
    word-break: break-word;
}

.detail-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.edit-detail-button,
.confirm-detail-button {
    flex: 1;
    padding: 20px;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 60px;
}

.edit-detail-button {
    background-color: #ff8c42;
    color: white;
}

.edit-detail-button:active {
    background-color: #e67a2e;
}

.confirm-detail-button {
    background-color: #4caf50;
    color: white;
}

.confirm-detail-button:active {
    background-color: #45a049;
}

.confirm-detail-button.confirmed {
    background-color: #2e7d32;
}

/* Clickable Rows */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.clickable-row:active {
    background-color: #fff9e6 !important;
}

.confirmed-row {
    background-color: #c8e6c9 !important;
}

.confirmed-row td {
    border-right: 1px solid #a5d6a7;
    border-bottom: 1px solid #a5d6a7;
}

.confirmed-row .status-cell {
    color: #2e7d32;
    font-size: 1.2rem;
    font-weight: bold;
}

.status-cell {
    text-align: center;
    width: 60px;
}

/* Utility Classes */
.hidden {
    display: none;
}

/* Touch-friendly spacing */
@media (max-width: 767px) {
    .container {
        padding: 15px;
    }

    th, td {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
}
