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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #667eea;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

header h1 {
    color: #333;
    font-size: 2em;
}

.search-bar {
    margin-bottom: 30px;
}

.search-bar input {
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: white;
}

.sneaker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.sneaker-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.sneaker-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
}

.sneaker-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f0f0f0;
}

.sneaker-info {
    padding: 20px;
}

.sneaker-brand {
    font-size: 0.9em;
    color: #667eea;
    font-weight: 600;
    text-transform: uppercase;
}

.sneaker-model {
    font-size: 1.3em;
    font-weight: bold;
    margin: 5px 0;
    color: #333;
}

.sneaker-colorway {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 10px;
}

.sneaker-details {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.sneaker-size, .sneaker-condition {
    font-size: 0.9em;
    color: #666;
}

.sneaker-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

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

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

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
}

.image-input-group {
    display: flex;
    gap: 10px;
}

.image-input-group input {
    flex: 1;
}

#imagePreview {
    margin-top: 10px;
}

#imagePreview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.image-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.image-result {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.image-result:hover {
    border-color: #667eea;
}

.image-result img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.detail-content-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.detail-image {
    width: 100%;
    border-radius: 8px;
}

.detail-info h2 {
    margin-bottom: 20px;
    color: #333;
}

.detail-field {
    margin-bottom: 15px;
}

.detail-label {
    font-weight: 600;
    color: #666;
    font-size: 0.9em;
    text-transform: uppercase;
}

.detail-value {
    margin-top: 5px;
    color: #333;
    font-size: 1.1em;
}

.datamatrix-container {
    margin-top: 20px;
    text-align: center;
}

.datamatrix-container img {
    max-width: 200px;
    border: 1px solid #ddd;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.empty-state h2 {
    color: #333;
    margin-bottom: 10px;
}

.empty-state p {
    color: #666;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .detail-content-inner {
        grid-template-columns: 1fr;
    }

    header {
        flex-direction: column;
        gap: 15px;
    }

    header h1 {
        font-size: 1.5em;
    }
}

.image-help {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.9em;
    line-height: 1.6;
}

.image-help strong {
    color: #667eea;
}

.image-help ol {
    margin: 10px 0 10px 20px;
    padding: 0;
}

.image-help li {
    margin: 5px 0;
}

.image-help p {
    margin: 10px 0 0 0;
    color: #666;
}

.image-help em {
    color: #999;
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #667eea;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-box h1 {
    margin-bottom: 10px;
    color: #333;
}

.login-box p {
    color: #666;
    margin-bottom: 30px;
}

.login-box input {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 15px;
}

.login-box button {
    width: 100%;
}

.login-error {
    color: #ef4444;
    margin-top: 15px;
    font-size: 0.9em;
}

/* Filters Bar */
.filters-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.filters-bar input,
.filters-bar select {
    padding: 12px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .filters-bar {
        grid-template-columns: 1fr;
    }
}

/* Filters Bar */
.filters-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.filters-bar input,
.filters-bar select {
    padding: 12px 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .filters-bar {
        grid-template-columns: 1fr;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 1.5em;
        text-align: center;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    .sneaker-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .sneaker-card {
        border-radius: 10px;
    }
    
    .sneaker-image {
        height: 250px;
    }
    
    .sneaker-info {
        padding: 15px;
    }
    
    .sneaker-model {
        font-size: 1.2em;
    }
    
    .sneaker-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .sneaker-actions .btn-small {
        width: 100%;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal h2 {
        font-size: 1.5em;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .detail-content-inner {
        grid-template-columns: 1fr !important;
    }
    
    .detail-image {
        max-height: 300px;
        width: 100%;
    }
    
    .datamatrix-container {
        margin-top: 20px;
    }
    
    /* Login screen */
    .login-container {
        width: 90%;
        max-width: 90%;
        padding: 30px 20px;
    }
    
    .login-container h1 {
        font-size: 1.8em;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Touch-friendly tap targets */
    button,
    input,
    select,
    .sneaker-card {
        min-height: 44px; /* iOS recommended minimum */
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3em;
    }
    
    .filters-bar input,
    .filters-bar select {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .sneaker-image {
        height: 200px;
    }
    
    .modal-content {
        width: 98%;
        margin: 5px;
    }
}

/* Image Search Results */
.image-search-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.image-search-item {
    position: relative;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
    aspect-ratio: 1;
}

.image-search-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-search-item:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.image-search-item.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px #667eea;
}

#selectedImagePreview {
    margin-top: 15px;
}

#selectedImagePreview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.image-search-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

@media (max-width: 768px) {
    .image-search-results {
        grid-template-columns: repeat(2, 1fr);
    }
}
