/**
 * AlertOwl - Dashboard Styles
 * Styles specific to the dashboard (dashboard.html)
 * Works alongside auth.css for common styles
 */

/* ===========================================
   DASHBOARD LAYOUT
   =========================================== */
.dashboard-container {
    min-height: 100vh;
}

/* ===========================================
   SIDEBAR
   =========================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.sidebar-logo svg {
    width: 32px;
    height: 32px;
}

.sidebar-logo span {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-teal);
}

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

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

/* ===========================================
   NAVIGATION
   =========================================== */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.2s;
    cursor: pointer;
}

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

.nav-item.active {
    background: rgba(20, 184, 166, 0.1);
    color: var(--accent-teal);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ===========================================
   SIDEBAR USER INFO
   =========================================== */
.sidebar-user {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

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

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-teal-dim) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

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

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

.btn-logout {
    width: 100%;
    padding: 10px;
    font-size: 14px;
}

/* ===========================================
   MAIN CONTENT AREA
   =========================================== */
.main-content {
    margin-left: 280px;
    padding: 32px 40px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-secondary);
}

/* ===========================================
   CARDS
   =========================================== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

/* ===========================================
   CONNECTIONS GRID
   =========================================== */
.connections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.connection-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.2s;
}

.connection-card:hover {
    border-color: var(--border-light);
}

.connection-card.connected {
    border-color: var(--accent-green);
}

.connection-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.connection-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.connection-icon.gmail {
    background: rgba(234, 67, 53, 0.1);
}

.connection-icon.outlook {
    background: rgba(0, 120, 212, 0.1);
}

.connection-icon.whatsapp {
    background: rgba(37, 211, 102, 0.1);
}

.connection-name {
    font-size: 18px;
    font-weight: 600;
}

.connection-desc {
    font-size: 14px;
    color: var(--text-muted);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.connected {
    background: var(--accent-green);
}

.status-dot.disconnected {
    background: var(--text-muted);
}

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

/* ===========================================
   AI MODULES GRID
   =========================================== */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.module-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
}

.module-card.active {
    border-color: var(--accent-teal);
}

.module-card.inactive {
    opacity: 0.6;
}

.module-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.module-badge.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
}

.module-badge.trial {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-yellow);
}

.module-badge.inactive {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.module-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
    background: rgba(20, 184, 166, 0.1);
}

.module-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.module-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.module-price {
    font-size: 14px;
    color: var(--accent-teal);
    font-weight: 600;
}

/* ===========================================
   STATS GRID
   =========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.stat-value.critical {
    color: var(--accent-red);
}

.stat-value.high {
    color: var(--accent-orange);
}

.stat-value.medium {
    color: var(--accent-yellow);
}

.stat-value.low {
    color: var(--accent-green);
}

/* ===========================================
   MESSAGES SECTION
   =========================================== */
.messages-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

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

.messages-title {
    font-size: 18px;
    font-weight: 600;
}

.messages-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

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

.messages-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    white-space: nowrap;
}

.messages-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

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

.messages-table tr:hover td {
    background: var(--bg-tertiary);
}

/* ===========================================
   PRIORITY & CATEGORY BADGES
   =========================================== */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.priority-badge.critical {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.priority-badge.high {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent-orange);
}

.priority-badge.medium {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-yellow);
}

.priority-badge.low {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
}

.category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===========================================
   FILTER & SETTINGS
   =========================================== */
.filter-select {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* ===========================================
   TRIAL BANNER
   =========================================== */
.trial-banner {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(249, 115, 22, 0.1) 100%);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.trial-text {
    color: var(--accent-yellow);
    font-weight: 500;
}

/* ===========================================
   EMPTY STATE & LOADING
   =========================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* ===========================================
   PAGE VISIBILITY
   =========================================== */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ===========================================
   PAGINATION
   =========================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===========================================
   SENTIMENT BADGES
   =========================================== */
.sentiment-positive { color: var(--accent-green); }
.sentiment-negative { color: var(--accent-red); }
.sentiment-neutral { color: var(--text-muted); }

/* ===========================================
   ACTION BADGES
   =========================================== */
.action-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ===========================================
   MOBILE BOTTOM NAVIGATION
   =========================================== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 1000;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    transition: color 0.2s;
    cursor: pointer;
}

.mobile-nav-item svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.mobile-nav-item.active {
    color: var(--accent-teal);
}

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

/* ===========================================
   BOTTOM SHEET - FIXED VERSION
   =========================================== */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 99998;
}

.bottom-sheet-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    z-index: 99999;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.bottom-sheet.active {
    transform: translateY(0) !important;
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 12px auto;
}

.bottom-sheet-content {
    padding: 8px 16px 32px;
}

.bottom-sheet-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 12px;
    transition: background 0.2s;
    cursor: pointer;
}

.bottom-sheet-item:hover,
.bottom-sheet-item:active {
    background: var(--bg-tertiary);
}

.bottom-sheet-item svg {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.bottom-sheet-item span {
    font-size: 16px;
    font-weight: 500;
}

.bottom-sheet-item.danger {
    color: #ef4444;
}

.bottom-sheet-item.danger svg {
    color: #ef4444;
}

.bottom-sheet-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
        padding-bottom: 100px; /* Space for mobile nav */
    }
    
    .stats-grid,
    .settings-grid,
    .connections-grid {
        grid-template-columns: 1fr;
    }
    
    .mobile-nav {
        display: flex;
    }

    /* ===========================================
       MOBILE MESSAGES - CARD LAYOUT
       =========================================== */
    .messages-table {
        display: block;
    }
    
    .messages-table thead {
        display: none; /* Hide table headers on mobile */
    }
    
    .messages-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    
    .messages-table tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-tertiary);
        border-radius: 12px;
        padding: 16px;
        gap: 12px;
        border: 1px solid var(--border);
    }
    
    .messages-table tr:hover td {
        background: transparent;
    }
    
    .messages-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0;
        border: none;
        font-size: 14px;
    }
    
    .messages-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 11px;
        text-transform: uppercase;
        min-width: 80px;
        flex-shrink: 0;
    }
    
   /* Source - show icon at top */
    .messages-table td:first-child {
        order: -3;
        margin-bottom: 4px;
    }
    
    .messages-table td:first-child::before {
        display: none;
    }
    
    /* Priority - make prominent */
    .messages-table td:nth-child(2) {
        order: -2;
        margin-bottom: 4px;
    }
    
    .messages-table td:nth-child(2)::before {
        display: none;
    }
    
    /* Category - show it */
    .messages-table td:nth-child(3) {
        order: -1;
        display: flex;
    }
    
    /* From field - make it stand out (column 6) */
    .messages-table td:nth-child(6) {
        order: 0;
        font-size: 14px;
        font-weight: 600 !important;
        color: var(--text-primary);
        border-bottom: 1px solid var(--border);
        padding-bottom: 12px !important;
        margin-bottom: 4px;
        word-break: break-all;
    }
    
    /* Subject - full width, wrap text (column 7) */
    .messages-table td:nth-child(7) {
        max-width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }
    
    /* Hide Sentiment and Action on mobile to reduce clutter */
    .messages-table td:nth-child(4), /* Sentiment */
    .messages-table td:nth-child(5) { /* Action */
        display: none;
    }
}
