/* 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: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #1d1d1f;
}

/* Main Navigation */
.main-nav {
    display: flex;
    gap: 16px;
    margin-bottom: 30px;
    justify-content: center;
}

.btn-large {
    flex: 1;
    max-width: 400px;
    font-size: 1.2rem;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-icon {
    font-size: 1.5rem;
}

/* View Sections */
.view-section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-description {
    color: #6e6e73;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Card Component */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #1d1d1f;
}

.card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 24px 0 16px 0;
    color: #1d1d1f;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input[type="file"] {
    padding: 10px;
}

.form-group input:focus {
    outline: none;
    border-color: #0071e3;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
}

.radio-group input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

/* Photo Preview */
.photo-preview {
    margin-top: 12px;
    display: none;
}

.photo-preview.active {
    display: block;
}

.photo-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid #d2d2d7;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    border: 4px solid #e8e8ed;
    border-top: 4px solid #0071e3;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Check Results */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.match-card {
    background: #f5f5f7;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.match-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.match-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
}

.match-info h4 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #1d1d1f;
}

.match-info p {
    font-size: 0.9rem;
    color: #6e6e73;
    margin-bottom: 4px;
}

.match-score {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
}

.match-percentage {
    font-size: 1.3rem;
    font-weight: 700;
}

.match-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.confidence-high {
    background: #d1f4e0;
    color: #0a6e31;
}

.confidence-medium {
    background: #fff3cd;
    color: #856404;
}

.confidence-low {
    background: #f8d7da;
    color: #721c24;
}

.not-found-message,
.error-message {
    text-align: center;
    padding: 40px 20px;
}

.not-found-message h3,
.error-message h3 {
    font-size: 1.3rem;
    margin-bottom: 12px;
    color: #1d1d1f;
}

.not-found-message p,
.error-message p {
    color: #6e6e73;
    margin-bottom: 24px;
}

.error-message {
    background: #fff3f3;
    border-radius: 8px;
    border: 1px solid #ff3b30;
}

.error-message h3 {
    color: #ff3b30;
}

/* Item Details */
.btn-back {
    margin-bottom: 20px;
}

.item-detail-header {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.item-detail-photo {
    width: 300px;
    height: 300px;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s;
}

.item-detail-photo:hover {
    transform: scale(1.02);
}

.item-detail-info {
    flex: 1;
    min-width: 250px;
}

.item-detail-info h2 {
    font-size: 1.8rem;
    margin-bottom: 12px;
}

.item-detail-info p {
    font-size: 1.1rem;
    color: #6e6e73;
    margin-bottom: 20px;
}

.item-detail-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.item-sales-history {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sale-history-item {
    background: #f5f5f7;
    padding: 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.sale-history-info p {
    font-size: 0.9rem;
    color: #1d1d1f;
    margin-bottom: 4px;
}

.sale-history-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.btn-primary {
    background-color: #0071e3;
    color: white;
}

.btn-primary:hover {
    background-color: #0077ed;
}

.btn-primary:active {
    background-color: #006edb;
}

.btn-secondary {
    background-color: #e8e8ed;
    color: #1d1d1f;
}

.btn-secondary:hover {
    background-color: #d2d2d7;
}

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

.btn-danger:hover {
    background-color: #ff453a;
}

.btn-edit {
    background-color: #30b0c7;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-delete {
    background-color: #ff3b30;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions button {
    flex: 1;
}

/* Messages */
.message {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    display: none;
    font-size: 0.95rem;
}

.message.active {
    display: block;
}

.message.success {
    background-color: #d1f4e0;
    color: #0a6e31;
    border: 1px solid #34c759;
}

.message.error {
    background-color: #ffd9d6;
    color: #c41e1e;
    border: 1px solid #ff3b30;
}

/* Statistics Section */
.stats-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e8e8ed;
    padding-bottom: 0;
}

.stats-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 500;
    color: #6e6e73;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.stats-tab:hover {
    color: #1d1d1f;
}

.stats-tab.active {
    color: #0071e3;
    border-bottom-color: #0071e3;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    color: white;
}

.stat-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stats-breakdown {
    max-height: 400px;
    overflow-y: auto;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f5f5f7;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: transform 0.2s;
}

.breakdown-item:hover {
    transform: translateX(4px);
    background: #e8e8ed;
}

.breakdown-period {
    font-weight: 600;
    color: #1d1d1f;
    font-size: 1rem;
}

.breakdown-stats {
    text-align: right;
}

.breakdown-count {
    font-size: 0.85rem;
    color: #6e6e73;
    margin-bottom: 4px;
}

.breakdown-total {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0071e3;
}

.stats-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6e6e73;
    font-size: 1rem;
}

/* Filters */
.filters {
    margin-bottom: 20px;
}

.filter-group {
    margin-bottom: 12px;
}

.filter-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #6e6e73;
}

.filter-group input[type="text"],
.filter-group input[type="date"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 0.95rem;
}

.filter-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-row .filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-row button {
    margin-bottom: 0;
}

/* History Actions */
.history-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.sales-count {
    font-size: 0.95rem;
    color: #6e6e73;
    font-weight: 500;
}

/* Find Item List */
.find-item-stats {
    margin-bottom: 20px;
    text-align: right;
}

.find-item-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.find-item-card {
    background: #f5f5f7;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.find-item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.find-item-photo {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.find-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.find-item-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1d1d1f;
}

.find-item-info p {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #6e6e73;
}

.find-item-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: #6e6e73;
    margin-bottom: 12px;
}

/* Inventory List */
.inventory-stats {
    margin-bottom: 20px;
    text-align: right;
}

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

.inventory-item {
    background: #f5f5f7;
    border-radius: 12px;
    padding: 16px;
    padding-bottom: 24px;
    border: 2px solid #d2d2d7;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.inventory-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.inventory-photo {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
    background-color: #e8e8ed;
}

.inventory-details h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1d1d1f;
}

.inventory-details p {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #6e6e73;
}

.inventory-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-top: 12px;
}

.inventory-stat {
    font-size: 0.85rem;
    color: #1d1d1f;
}

.inventory-stat strong {
    color: #6e6e73;
    font-weight: 500;
}

.inventory-stat-empty {
    font-size: 0.9rem;
    color: #6e6e73;
    font-style: italic;
}

/* Sales List */
.sales-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: #6e6e73;
    padding: 40px 20px;
    font-size: 1.1rem;
}

.sale-item {
    background: #f5f5f7;
    border-radius: 12px;
    padding: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.sale-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sale-photo {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
    background-color: #e8e8ed;
}

.sale-details {
    font-size: 0.9rem;
}

.sale-details h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1d1d1f;
}

.sale-details p {
    margin-bottom: 6px;
    color: #6e6e73;
}

.sale-details strong {
    color: #1d1d1f;
}

.sale-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #0071e3;
    margin: 8px 0;
}

.sale-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.sale-actions button {
    flex: 1;
}

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

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

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    margin: 20px;
}

.modal-content h3 {
    font-size: 1.3rem;
    margin-bottom: 16px;
    color: #1d1d1f;
}

.modal-content p {
    margin-bottom: 24px;
    color: #6e6e73;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions button {
    flex: 1;
}

/* Photo Modal */
.photo-modal-content {
    max-width: 90%;
    max-height: 90%;
    padding: 0;
    position: relative;
}

.photo-modal-content img {
    width: 100%;
    height: auto;
    border-radius: 16px;
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.close-modal:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Responsive Design - Mobile First */
@media (max-width: 767px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 16px;
    }

    .card h2 {
        font-size: 1.25rem;
    }

    .main-nav {
        flex-direction: column;
    }

    .btn-large {
        max-width: none;
    }

    .item-detail-header {
        flex-direction: column;
    }

    .item-detail-photo {
        width: 100%;
        height: auto;
    }

    .item-detail-actions {
        flex-direction: column;
    }

    .item-detail-actions button {
        width: 100%;
    }

    .sales-list {
        grid-template-columns: 1fr;
    }

    .inventory-list {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-row .filter-group {
        width: 100%;
    }

    .history-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .matches-grid {
        grid-template-columns: 1fr;
    }
}

/* iPad Portrait */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 24px;
    }

    .sales-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .inventory-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .matches-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* iPad Landscape and Desktop */
@media (min-width: 1025px) {
    .sales-list {
        grid-template-columns: repeat(3, 1fr);
    }

    .inventory-list {
        grid-template-columns: repeat(3, 1fr);
    }

    .matches-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .card {
        box-shadow: none;
        page-break-inside: avoid;
    }

    .main-nav,
    .view-section,
    .filters,
    .history-actions,
    .sale-actions,
    .item-detail-actions,
    .btn {
        display: none !important;
    }

    .sale-item {
        page-break-inside: avoid;
    }
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #34c759;
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
