/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * PORTER+CRAIG RIGHTS CONTROL CENTER v2.0
 * Command Center Dark Theme
 * ═══════════════════════════════════════════════════════════════════════════════
 */

:root {
    /* Command Center Dark Theme */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #16161f;
    --bg-hover: #1e1e2a;
    
    /* Accent Colors */
    --accent-gold: #d4af37;
    --accent-gold-dim: rgba(212, 175, 55, 0.15);
    --accent-crimson: #dc2626;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    
    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #6b7280;
    
    /* Borders */
    --border-color: #2a2a35;
    --border-light: rgba(255,255,255,0.05);
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #3b82f6;
    
    /* Sizing */
    --sidebar-width: 260px;
    --header-height: 64px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-gold), #b8962d);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: var(--bg-primary);
}

.logo-text {
    font-weight: 600;
    font-size: 15px;
}

.logo-text span {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 11px;
    display: block;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    padding: 8px 12px;
    margin: 16px 12px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.back-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s ease;
    font-size: 14px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-gold-dim);
    color: var(--accent-gold);
}

.nav-item i {
    font-size: 18px;
    width: 20px;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-crimson);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.nav-badge.new {
    background: var(--accent-emerald);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--bg-primary);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.page-content {
    flex: 1;
    padding: 24px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════════════════════════ */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-change {
    font-size: 12px;
    margin-top: 8px;
}

.stat-change.positive { color: var(--accent-emerald); }
.stat-change.negative { color: var(--accent-crimson); }

/* ═══════════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn:hover {
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--accent-gold);
    color: var(--bg-primary);
    border-color: var(--accent-gold);
}

.btn-primary:hover {
    background: #e5c347;
}

.btn-success {
    background: var(--accent-emerald);
    color: white;
    border-color: var(--accent-emerald);
}

.btn-warning {
    background: var(--accent-amber);
    color: var(--bg-primary);
    border-color: var(--accent-amber);
}

.btn-danger {
    background: var(--accent-crimson);
    color: white;
    border-color: var(--accent-crimson);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════════════ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.data-table tr:hover {
    background: var(--bg-hover);
}

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

/* ═══════════════════════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.badge-danger { background: rgba(220, 38, 38, 0.15); color: var(--accent-crimson); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-gold { background: var(--accent-gold-dim); color: var(--accent-gold); }

/* ═══════════════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════════════ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.form-input::placeholder {
    color: var(--text-muted);
}

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

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CONFIDENCE METER
   ═══════════════════════════════════════════════════════════════════════════════ */
.confidence-meter {
    display: flex;
    align-items: center;
    gap: 12px;
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.confidence-fill.high { background: var(--accent-emerald); }
.confidence-fill.medium { background: var(--accent-amber); }
.confidence-fill.low { background: var(--accent-crimson); }

.confidence-label {
    font-size: 13px;
    font-weight: 600;
    min-width: 45px;
    text-align: right;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UPLOAD ZONE
   ═══════════════════════════════════════════════════════════════════════════════ */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    transition: all 0.15s ease;
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-gold);
    background: var(--accent-gold-dim);
}

.upload-zone i {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.upload-zone p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.upload-zone .upload-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ALERTS & NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.alert-item:last-child {
    border-bottom: none;
}

.alert-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.alert-icon.critical { background: rgba(220, 38, 38, 0.15); color: var(--accent-crimson); }
.alert-icon.high { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.alert-icon.medium { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.alert-icon.low { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

.alert-content {
    flex: 1;
}

.alert-message {
    font-size: 14px;
    margin-bottom: 4px;
}

.alert-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   GRID SYSTEM
   ═══════════════════════════════════════════════════════════════════════════════ */
.grid {
    display: grid;
    gap: 24px;
}

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

@media (max-width: 1200px) {
    .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CHECKLIST
   ═══════════════════════════════════════════════════════════════════════════════ */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.checklist-icon.delivered { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.checklist-icon.pending { background: var(--bg-tertiary); color: var(--text-muted); }
.checklist-icon.failed { background: rgba(220, 38, 38, 0.15); color: var(--accent-crimson); }

.checklist-info {
    flex: 1;
}

.checklist-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.checklist-spec {
    font-size: 12px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TERRITORY MAP
   ═══════════════════════════════════════════════════════════════════════════════ */
.territory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.territory-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    transition: all 0.15s ease;
    cursor: pointer;
}

.territory-card:hover {
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.territory-card.available { border-color: var(--accent-emerald); background: rgba(16, 185, 129, 0.05); }
.territory-card.licensed { border-color: var(--accent-blue); background: rgba(59, 130, 246, 0.05); }
.territory-card.exclusive { border-color: var(--accent-gold); background: var(--accent-gold-dim); }
.territory-card.expired { border-color: var(--text-muted); opacity: 0.6; }
.territory-card.expiring { border-color: var(--accent-amber); background: rgba(245, 158, 11, 0.05); }

.territory-code {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.territory-name {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════════════════════ */
.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.success { background: var(--accent-emerald); }
.progress-fill.warning { background: var(--accent-amber); }
.progress-fill.danger { background: var(--accent-crimson); }

/* ═══════════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-crimson); }
.toast.warning { border-left: 4px solid var(--accent-amber); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════════════════════════ */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
    cursor: pointer;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   EXTRACTION FIELDS
   ═══════════════════════════════════════════════════════════════════════════════ */
.extraction-field {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 12px;
}

.extraction-field .field-info {
    flex: 1;
}

.extraction-field .field-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.extraction-field .field-value {
    font-size: 16px;
    font-weight: 500;
}

.extraction-field .field-source {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.extraction-field .field-confidence {
    text-align: right;
}
