/* === Base Reset & Typography === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.5;
    min-height: 100vh;
}

/* === Container === */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 15px;
}

/* === Header === */
h1 {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 10px 0 15px;
    letter-spacing: 0.5px;
}

/* === Search Form === */
.search-form {
    margin-bottom: 15px;
}

.input-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

input[type="text"] {
    width: 100%;
    max-width: 500px;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

input[type="text"]:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.buttons-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
    min-height: 44px;
    min-width: 44px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-search {
    background-color: #4CAF50;
    color: white;
}

.btn-search:hover {
    background-color: #43a047;
}

.btn-scanner {
    background-color: #2196F3;
    color: white;
}

.btn-scanner:hover {
    background-color: #1e88e5;
}

.btn-history {
    background-color: #78909c;
    color: white;
}

.btn-history:hover {
    background-color: #607d8b;
}

/* === Results Info === */
.results-info {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

/* === Table === */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 0.9rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    background-color: #2c3e50;
    padding: 10px 8px;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

th a {
    color: #ecf0f1;
    text-decoration: none;
}

th a:hover {
    color: #4CAF50;
}

td {
    padding: 9px 8px;
    border-bottom: 1px solid #eee;
}

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

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

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

td.name {
    text-align: left;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

td.price {
    text-align: right;
    font-weight: 600;
    color: #2e7d32;
    white-space: nowrap;
}

.no-results {
    text-align: center;
    padding: 30px;
    color: #999;
    font-style: italic;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    flex-wrap: wrap;
    gap: 4px;
}

.pagination a {
    color: #333;
    padding: 8px 14px;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.pagination a:hover {
    background-color: #e8e8e8;
}

.pagination a.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
    font-weight: 600;
}

/* === Scanner Overlay === */
#scanner-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.9);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#interactive {
    width: 100%;
    max-width: 500px;
    height: 60vh;
    position: relative;
}

#interactive video,
#interactive canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

#close-scanner {
    position: relative;
    z-index: 1010;
    margin-top: 20px;
    padding: 16px 50px;
    font-size: 18px;
    font-weight: 600;
    background-color: #e74c3c;
    color: white;
    border: none;
    -webkit-tap-highlight-color: rgba(255,255,255,0.3);
    touch-action: manipulation;
    border-radius: 8px;
    cursor: pointer;
    min-height: 48px;
}

#close-scanner:hover {
    background-color: #c0392b;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.3rem;
        margin: 8px 0 12px;
    }

    input[type="text"] {
        padding: 10px 12px;
        font-size: 16px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
        flex: 1;
        min-width: 0;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 7px 5px;
    }

    td.name {
        max-width: 150px;
    }

    .pagination a {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    #interactive {
        height: 70vh;
        max-width: 100%;
    }
}

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

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

    td.name {
        max-width: 120px;
    }

    .btn {
        padding: 9px 12px;
        font-size: 13px;
    }
}
