/* ========================================
   RESELLER PRO - MAIN STYLESHEET
   Version 6.0 - Modular CSS (Extracted from View Files)
   Last Updated: January 5, 2026
   ======================================== */

/* ========================================
   GLOBAL RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.login-box h1 {
    font-size: 28px;
    margin-bottom: 5px;
    color: #667eea;
}

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

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

.login-box button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.login-box button:hover {
    background: #764ba2;
}

.alert-error {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
}

/* ========================================
   GRADIENT HEADER (Used on Items, Research, Upload, Analytics)
   ======================================== */
.items-header {
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 50%, #a855f7 100%);
    border-radius: 12px;
    padding: 30px 40px;
    margin-bottom: 30px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.items-header-left h1 {
    font-size: 28px;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.items-header-left p {
    margin: 0 0 15px 0;
    opacity: 0.9;
    font-size: 15px;
}

.items-header-pills {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.items-header-pill {
    background: rgba(15, 23, 42, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.items-header-pill span:first-child {
    font-size: 16px;
}

.items-header-pill span:nth-child(2) {
    font-weight: 700;
    font-size: 16px;
}

.items-header-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-header {
    padding: 8px 14px;
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-header:hover {
    background: rgba(255,255,255,0.35);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ========================================
   ANALYTICS PAGE STYLES
   ======================================== */
.analytics-header {
    padding: 20px;
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 50%, #a855f7 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-radius: 8px;
    margin-bottom: 20px;
}

.analytics-header h1 {
    margin: 0;
    font-size: 24px;
}

.analytics-subtitle {
    margin-top: 4px;
    font-size: 13px;
    opacity: 0.95;
}

.analytics-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.analytics-filters {
    display: flex;
    gap: 8px;
    align-items: center;
}

.analytics-filters select,
.analytics-filters input {
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: rgba(15, 23, 42, 0.16);
    color: white;
    font-size: 12px;
}

.analytics-filters option {
    color: #111827;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    background: white;
    border-radius: 8px;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metric-label {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric-value {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.metric-sub {
    font-size: 11px;
    color: #9ca3af;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
}

.metric-pill.good {
    background: #dcfce7;
    color: #166534;
}

.metric-pill.warn {
    background: #fef3c7;
    color: #92400e;
}

.metric-pill.bad {
    background: #fee2e2;
    color: #b91c1c;
}

.analytics-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr);
    gap: 16px;
}

.panel {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: 12px 14px 16px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.panel-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-header span.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
}

.panel-description {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 10px;
}

.panel-body {
    min-height: 180px;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.chart-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chart-meta {
    font-size: 11px;
    color: #6b7280;
    display: flex;
    justify-content: space-between;
}

.chart-canvas-container {
    background: #f9fafb;
    border-radius: 8px;
    border: 1px dashed #e5e7eb;
    padding: 8px;
    position: relative;
    height: 210px;
}

canvas.analytics-chart {
    width: 100%;
    height: 100%;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #9ca3af;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #6b7280;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 6px;
}

.summary-table th,
.summary-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #f3f4f6;
    text-align: left;
    white-space: nowrap;
}

.summary-table th {
    font-weight: 600;
    color: #6b7280;
}

.summary-table td {
    color: #111827;
}

.summary-table tr:last-child td {
    border-bottom: none;
}

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 11px;
}

.badge-soft.blue {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-soft.green {
    background: #ecfdf3;
    color: #15803d;
}

.badge-soft.yellow {
    background: #fffbeb;
    color: #92400e;
}

.badge-soft.red {
    background: #fef2f2;
    color: #b91c1c;
}

.analytics-loading {
    text-align: center;
    padding: 20px 0;
    color: #9ca3af;
    font-size: 12px;
}

.analytics-loading::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid #e5e7eb;
    border-top-color: #6366f1;
    margin-left: 6px;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   ITEMS PAGE STYLES
   ======================================== */
.items-table-wrapper {
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow-x: auto;
}

.items-list {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.items-list thead {
    background: #f8fafc;
}

.items-list th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid #e5e7eb;
}

.items-list td {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.items-list tbody tr:hover {
    background: #f8fafc;
}

/* Photo Thumbnail Styling */
.photo-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    cursor: pointer;
}

.photo-wrapper:hover .item-photo {
    box-shadow: 0 0 0 2px #6366f1;
}

.item-photo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    transition: all 0.2s;
}

.placeholder-image {
    width: 60px;
    height: 60px;
    background: #e5e7eb;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #94a3b8;
}

/* Photo Count Badge */
.photo-count-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(99, 102, 241, 0.95);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Action Buttons */
.btn-sm {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    margin-right: 4px;
}

.btn-edit {
    background: #3b82f6;
    color: white;
}

.btn-edit:hover {
    background: #2563eb;
}

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

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: #475569;
    margin-bottom: 8px;
}

/* ========================================
   RESEARCH PAGE STYLES
   ======================================== */
.research-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.research-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
    align-items: start;
}

.research-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    align-self: start;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.panel-header .icon {
    font-size: 28px;
}

.panel-header h2 {
    font-size: 20px;
    color: #111827;
    margin: 0;
    font-weight: 600;
}

.panel-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Items Table */
.items-table-container {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table thead {
    background: #f9fafb;
}

.items-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.items-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
}

.items-table tbody tr:hover {
    background: #f9fafb;
}

.items-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: #374151;
}

.items-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Export Controls */
.export-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

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

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.selected-badge {
    display: inline-block;
    background: white;
    color: #3b82f6;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 5px;
}

/* Prompt Display */
.prompt-display {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #374151;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 15px;
}

#prompt-container {
    margin-top: 20px;
    animation: slideDown 0.3s ease-out;
    /* **FIX FOR BUG #2: Prevent layout breaking** */
    max-width: 100%;
    overflow-x: auto;
    width: 100%; /* ← ADD THIS */
    box-sizing: border-box; /* ← ADD THIS */
}

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

/* Import Area */
.import-area {
    margin-bottom: 20px;
}

.import-area textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
}

.import-area textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Import Controls */
.import-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

/* Preview Table */
.preview-table-container {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}

/* ========================================
   UPLOAD PAGE STYLES
   ======================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Upload Section */
.upload-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.upload-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #1e293b;
}

.drop-zone {
    border: 3px dashed #cbd5e1;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #6366f1;
    background: #f1f5ff;
}

.drop-zone-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.drop-zone h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #1e293b;
}

.drop-zone p {
    color: #64748b;
    margin-bottom: 1rem;
}

.browse-btn {
    background: #6366f1;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.browse-btn:hover {
    background: #4f46e5;
}

.upload-info {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #64748b;
}

#uploadStatus {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    display: none;
}

/* Photo Gallery Section */
.gallery-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.gallery-header h2 {
    font-size: 1.5rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gallery-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-cancel {
    background: #e2e8f0;
    color: #475569;
}

.btn-cancel:hover {
    background: #cbd5e1;
}

.btn-submit {
    background: #6366f1;
    color: white;
}

.btn-submit:hover {
    background: #4f46e5;
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.photo-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
    background: #f8fafc;
    aspect-ratio: 1;
}

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

.photo-card.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 0.75rem;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.photo-id {
    font-weight: 600;
}

.photo-date {
    opacity: 0.9;
}

/* Delete Photo Button */
.delete-photo-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: 2px solid white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0;
    font-weight: bold;
}

.photo-card:hover .delete-photo-btn {
    opacity: 1;
}

.delete-photo-btn:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.1);
}

.delete-photo-btn:active {
    transform: scale(0.95);
}

/* ========================================
   MODAL STYLES (Shared across pages)
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0 0 8px 0;
    font-size: 20px;
}

.modal-header p {
    color: #64748b;
    font-size: 0.9rem;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
}

.modal-close:hover {
    color: #475569;
}

/* Form Styling */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: #475569;
}

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

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

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

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

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-primary:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    background: #e5e7eb;
    color: #475569;
}

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