/**
 * Stubs Deals - Clean Table Style
 */

:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-dark: #1a1a1a;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e0e0e0;
    --accent-primary: #3498db;
    --accent-success: #27ae60;
    --accent-danger: #e74c3c;
    --accent-warning: #f39c12;
    --highlight-bg: #fff3cd;
    --highlight-border: #ffc107;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   Header
   ============================================ */

header {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 24px 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.info-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.info-text strong {
    color: var(--text-primary);
}

/* ============================================
   Juice Toggle
   ============================================ */

.juice-toggle {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.juice-btn {
    flex: 1;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.juice-btn:hover {
    border-color: var(--accent-primary);
    background: #f8f9fa;
}

.juice-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.juice-btn .juice-desc {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    margin-top: 4px;
    opacity: 0.8;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ============================================
   Deals Section
   ============================================ */

.deals-section {
    margin-bottom: 40px;
}

.deals-section h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.reset-time {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ============================================
   Table
   ============================================ */

.table-container {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.deals-table {
    width: 100%;
    border-collapse: collapse;
}

.deals-table thead {
    background: var(--bg-primary);
}

.deals-table thead th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.deals-table thead th.highlight-col {
    background: var(--highlight-bg);
    color: var(--accent-warning);
    font-weight: 700;
}

.deals-table tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.deals-table tbody tr:last-child td {
    border-bottom: none;
}

.deals-table tbody tr:hover {
    background: #f8f9fa;
}

.deals-table tbody tr.profitable {
    background: #f0f9f4;
}

.deals-table tbody tr.profitable:hover {
    background: #e6f5ec;
}

.deals-table tbody tr.unavailable {
    opacity: 0.6;
    background: #fff5f5;
}

.deals-table tbody tr.unavailable:hover {
    background: #ffe5e5;
}

/* Table Columns */
.deals-table td.item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.deals-table td.item-id {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.deals-table td.amount {
    text-align: center;
    font-weight: 500;
}

.deals-table td.price {
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

.deals-table td.stubs {
    font-weight: 600;
    color: var(--accent-warning);
}

.deals-table td.highlight-col {
    background: var(--highlight-bg);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.deals-table td.profit {
    font-weight: 600;
    color: var(--accent-success);
}

.deals-table td.loss {
    font-weight: 600;
    color: var(--accent-danger);
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-available {
    background: #d4edda;
    color: #155724;
}

.status-unavailable {
    background: #f8d7da;
    color: #721c24;
}

.status-profitable {
    background: #d1ecf1;
    color: #0c5460;
}

/* Loading & Empty States */
.loading, .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.error-message {
    color: var(--accent-danger);
    font-size: 0.85rem;
}

/* ============================================
   Footer
   ============================================ */

footer {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

footer p {
    margin: 5px 0;
    font-size: 0.9rem;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1200px) {
    .table-container {
        overflow-x: auto;
    }

    .deals-table {
        min-width: 900px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .settings-info {
        flex-direction: column;
        gap: 10px;
    }

    .deals-section h2 {
        font-size: 1.3rem;
    }

    .reset-time {
        display: block;
        margin-top: 5px;
    }
}

/* ============================================
   Admin Page Specific Styles
   ============================================ */

.admin-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.deals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.deal-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: all 0.2s;
}

.deal-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.deal-card.disabled {
    opacity: 0.5;
}

.deal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.deal-id {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: monospace;
}

.deal-actions {
    display: flex;
    gap: 8px;
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: var(--accent-success);
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.deal-info {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.deal-info:last-child {
    border-bottom: none;
}

.deal-info .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.deal-info .value {
    color: var(--text-primary);
    font-weight: 600;
}

.deal-info .value.highlight {
    color: var(--accent-warning);
}

.status-enabled {
    color: var(--accent-success);
}

.status-disabled {
    color: var(--accent-danger);
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input[readonly] {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

.help-text {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal form {
    padding: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.cache-status {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.status-item {
    padding: 15px;
    background: var(--bg-primary);
    border-radius: 6px;
    text-align: center;
}

.status-item .label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.status-item .value {
    display: block;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.status-ok {
    color: var(--accent-success) !important;
}

.status-error {
    color: var(--accent-danger) !important;
}

/* ============================================
   Search Section
   ============================================ */

.search-container {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 20px;
}

.search-results {
    margin-top: 20px;
}

.search-results-header {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.search-result-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.search-result-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-primary);
}

.search-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.search-item-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.search-item-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-daily {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-weekly {
    background: #fff3cd;
    color: #856404;
}

.search-item-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.search-detail-row .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.search-detail-row .value {
    color: var(--text-primary);
    font-weight: 600;
}

.search-detail-row .value.highlight {
    color: var(--accent-warning);
    font-size: 1.05rem;
}

.section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.deals-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.empty-message {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ============================================
   Autocomplete Suggestions
   ============================================ */

.suggestions-container {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    width: calc(100% - 24px);
}

.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-primary);
}

.suggestion-name {
    font-weight: 600;
    color: var(--text-primary);
}

.suggestion-id {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.auto-filled-label {
    font-size: 0.8rem;
    font-weight: 400;
    margin-left: 8px;
}

.form-group {
    position: relative;
}

/* ============================================
   Login Screen
   ============================================ */

.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-container {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
    padding: 12px;
}

#loginError {
    color: var(--accent-danger);
    font-size: 0.9rem;
    margin-top: 10px;
    padding: 8px 12px;
    background: #ffe5e5;
    border-radius: 4px;
    text-align: center;
}
