/* Reset & Base */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: #f5ede4;
    color: #3d2b1f;
}
h1, h2 { color: #4a2c1a; }
.brand { color: #8b5a2b; }

/* Info box */
.info-box {
    background: #e8d9c8;
    border-left: 4px solid #6b3a1f;
    padding: 10px 15px;
    margin: 15px 0;
    border-radius: 4px;
    font-size: 0.95rem;
}

/* Settings */
.settings {
    background: #fefcf7;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(60, 40, 20, 0.12);
    margin-bottom: 20px;
    border: 1px solid #d4c0ae;
}
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}
.settings-grid label {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.9rem;
    color: #4a2c1a;
}
.settings-grid input, .settings-grid select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #c9b39f;
    border-radius: 4px;
    background: white;
    font-size: 0.95rem;
}
.settings-grid .full-width { grid-column: 1 / -1; }
.settings-grid .helper-text {
    display: block;
    font-size: 0.7rem;
    color: #7a5e44;
    margin-top: 2px;
}
.inline-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}
.inline-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
}
.inline-checkbox label {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0;
    color: #4a2c1a;
}

/* Buttons */
.btn-generate {
    background: #6b3a1f;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 15px;
}
.btn-generate:hover { background: #4a2c1a; }

.btn-generate:disabled { opacity: 0.6; cursor: not-allowed; }

.cancel-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: 10px;
    margin-top: 15px;
}
.cancel-btn:hover { background: #c82333; }

/* Loading & Progress */
.loading {
    display: none;
    padding: 20px;
}
.loading.active { display: block; }
.progress-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 10px;
}
.step-container {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}
.step-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.step-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    font-weight: bold;
}
.step-icon.active { background: #6b3a1f; }
.step-icon.complete { background: #4a7a4a; }
.step-label { font-weight: 600; font-size: 0.9rem; }
.step-status { font-size: 0.8rem; color: #6c757d; margin-left: auto; }
.step-bar {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}
.step-bar-fill {
    height: 100%;
    width: 0%;
    background: #6b3a1f;
    transition: width 0.3s;
}
.step-detail {
    font-size: 0.8rem;
    color: #7a5e44;
    margin-top: 4px;
    min-height: 1.2em;
}

/* Summary card */
.summary-card {
    background: #fefcf7;
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 2px 6px rgba(60, 40, 20, 0.08);
    border: 1px solid #b0907a;
    border-left-width: 6px;
    margin: 0 auto 20px auto;
    max-width: 40%;
}
.summary-card h3 {
    margin-top: 0;
    border-bottom: 1px solid #d4c0ae;
    padding-bottom: 6px;
    font-size: 1.1rem;
    color: #4a2c1a;
}
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    font-size: 0.85rem;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 6px;
}
.summary-grid .label { font-weight: 600; color: #5a3f2b; padding: 2px 4px; }
.summary-grid span { padding: 2px 4px; }
.summary-grid .label:nth-child(odd),
.summary-grid span:nth-child(even) {
    background: #f0e6da;
}

/* Results grid */
.results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}
.pack-card {
    background: #fefcf7;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 6px rgba(60, 40, 20, 0.08);
    border: 1px solid #d4c0ae;
}
.pack-card h3 {
    margin-top: 0;
    padding: 6px 10px;
    border-radius: 6px 6px 0 0;
    background: #e8d9c8;
    border-bottom: 1px solid #d4c0ae;
    padding-bottom: 8px;
    color: #4a2c1a;
}
.pack-card .pack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 2px solid #d4c0ae;
    margin-bottom: 8px;
}
.pack-card .pack-header strong {
    font-size: 1.1rem;
}

/* Cigar items */
.cigar-item {
    padding: 4px 0;
    border-bottom: 1px solid #f5f5f5;
}
.cigar-brand {
    font-size: 0.7rem;
    color: #7a5e44;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cigar-name a {
    color: #3d2b1f;
    text-decoration: none;
}
.cigar-name a:hover { text-decoration: underline; }
.cigar-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cigar-price { font-weight: 600; }
.cigar-stock {
    font-size: 0.75rem;
    font-weight: 600;
}
.stock-in { color: #2d6a2d; }
.stock-out { color: #b33a2a; }
.repeat-tag {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}
.status-within { background: #2d6a2d; }
.status-out { background: #b33a2a; }

/* Swap Container */
.swap-container {
    position: sticky;
    bottom: 0;
    background: #fefcf7;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(60, 40, 20, 0.12);
    border: 1px solid #b0907a;
    max-height: 80vh;
    overflow-y: auto;
    margin-top: 30px;
    z-index: 100;
}
.swap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e8d9c8;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
}
.swap-header h3 { margin: 0; color: #4a2c1a; }
.swap-container .toggle-btn {
    background: #6b3a1f;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.swap-container .toggle-btn:hover { background: #4a2c1a; }

/* Swap controls */
.swap-controls {
    display: grid;
    grid-template-columns: 0.6fr 1.2fr 1.2fr auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 15px;
}
.swap-controls label {
    font-weight: 600;
    font-size: 0.85rem;
    display: block;
}
.swap-controls select {
    width: 100%;
    padding: 6px;
    border: 1px solid #c9b39f;
    border-radius: 4px;
}
.swap-controls button {
    background: #6b3a1f;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 4px;
}
.swap-controls button:hover { background: #4a2c1a; }

/* ===== SWAP LIST – RESPONSIVE FLEX COLUMNS ===== */
.swap-list-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.swap-item-card {
    flex: 1 0 calc(50% - 10px); /* 2 per row on mobile */
    max-width: 220px;
    background: #fefcf7;
    border: 1px solid #d4c0ae;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: left;
    box-sizing: border-box;
}

/* Tablet: 3 per row */
@media (min-width: 600px) {
    .swap-item-card {
        flex: 1 0 calc(33.33% - 10px);
        max-width: 240px;
    }
}

/* Desktop: 6 per row */
@media (min-width: 900px) {
    .swap-item-card {
        flex: 1 0 calc(16.66% - 10px);
        max-width: 260px;
    }
}

.swap-item-card .cigar-brand {
    font-size: 0.7rem;
    color: #7a5e44;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.swap-item-card .cigar-name a {
    color: #3d2b1f;
}
.swap-item-card .cigar-stock {
    font-size: 0.7rem;
    font-weight: 600;
}

/* Export buttons */
.export-btn {
    background: #7a5e44;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}
.export-btn:hover { background: #5a3f2b; }
.footer-actions {
    margin: 15px 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Cache info */
.cache-info {
    font-size: 0.85rem;
    color: #6c757d;
    margin: 5px 0;
}

/* Responsive */
@media (max-width: 900px) {
    .results { grid-template-columns: repeat(2, 1fr); }
    .progress-grid { grid-template-columns: repeat(2, 1fr); }
    .swap-controls { grid-template-columns: 1fr 1fr; }
    .summary-card { max-width: 60%; }
}
@media (max-width: 600px) {
    .results { grid-template-columns: 1fr; }
    .progress-grid { grid-template-columns: 1fr; }
    .swap-controls { grid-template-columns: 1fr; }
    .summary-card { max-width: 100%; }
}

/* Warning box */
.warning-box {
    background-color: #fff3cd;
    border: 2px solid #ffe69c;
    border-radius: 8px;
    padding: 15px 20px;
    margin: 10px 0 20px 0;
    color: #856404;
    font-size: 0.95rem;
    line-height: 1.5;
}