/**
 * ResiHub Panel System - 70% Slide-Out Modules
 * =============================================
 * Base CSS for all dashboard types (User, PM, Contractor, Admin)
 * 
 * Panel System:
 * - 70% width slide-out from right
 * - Resi-controlled via ui_action
 * - User-accessible via dock icons
 * - Module-based content loading
 */

/* ========== PANEL CONTAINER ========== */
.rh-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 9998;
}

.rh-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

.rh-slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 70%;
    height: 100%;
    background: var(--card-bg, #1d2e2a);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rh-slide-panel.open {
    transform: translateX(0);
}

/* Panel Header */
.rh-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--accent-primary, #18b090), var(--accent-golden, #eeae47));
    color: white;
    flex-shrink: 0;
}

.rh-panel-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rh-panel-title i {
    font-size: 1.2rem;
}

.rh-panel-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    position: relative;
}

.rh-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Panel Content */
.rh-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Panel Footer */
.rh-panel-footer {
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-accent, #eeae47);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

/* ========== DOCK ICONS ========== */
.rh-panel-dock {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9000;
}

.rh-dock-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: var(--card-bg, rgba(29, 46, 42, 0.95));
    border: 2px solid var(--accent-golden, #eeae47);
    color: var(--accent-golden, #eeae47);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.rh-dock-icon:hover {
    background: var(--accent-golden, #eeae47);
    color: var(--text-primary, #f5e6d3);
    transform: scale(1.1) translateX(-5px);
}

.rh-dock-icon.active {
    background: var(--accent-primary, #18b090);
    border-color: var(--accent-primary, #18b090);
    color: white;
}

/* Badge Count */
.rh-dock-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.rh-dock-badge:empty {
    display: none;
}

/* Tooltip */
.rh-dock-icon::before {
    content: attr(data-tooltip);
    position: absolute;
    right: 60px;
    background: var(--card-bg, #1d2e2a);
    color: var(--text-primary, #f5e6d3);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    border: 1px solid var(--accent-golden, #eeae47);
}

.rh-dock-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ========== MODULE CARDS INSIDE PANELS ========== */
.rh-module-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid rgba(238, 174, 71, 0.3);
}

.rh-module-card h3 {
    color: var(--accent-golden, #eeae47);
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Line Items (for estimates, invoices) */
.rh-line-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rh-line-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    align-items: center;
}

.rh-line-item-name {
    font-weight: 500;
}

.rh-line-item-qty {
    color: var(--text-secondary, #c2c3c3);
    font-size: 0.9rem;
}

.rh-line-item-price {
    color: var(--accent-primary, #18b090);
    font-weight: 600;
}

.rh-line-item-amazon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #ff9900;
    text-decoration: none;
    font-size: 0.85rem;
    margin-top: 4px;
}

.rh-line-item-amazon:hover {
    text-decoration: underline;
}

/* Totals */
.rh-totals {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid var(--accent-golden, #eeae47);
}

.rh-total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1rem;
}

.rh-total-row.grand-total {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-primary, #18b090);
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* ========== ACTION BUTTONS ========== */
.rh-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 0.95rem;
}

.rh-btn-primary {
    background: var(--accent-primary, #18b090);
    color: white;
}

.rh-btn-primary:hover {
    background: #14997d;
    transform: translateY(-2px);
}

.rh-btn-secondary {
    background: transparent;
    border: 2px solid var(--accent-golden, #eeae47);
    color: var(--accent-golden, #eeae47);
}

.rh-btn-secondary:hover {
    background: var(--accent-golden, #eeae47);
    color: var(--text-primary, #1d2e2a);
}

.rh-btn-amazon {
    background: linear-gradient(135deg, #ff9900, #ffad33);
    color: #111;
}

.rh-btn-amazon:hover {
    background: linear-gradient(135deg, #e68a00, #ff9900);
}

/* ========== RESI HINT INDICATOR ========== */
.rh-resi-hint {
    position: fixed;
    bottom: 100px;
    right: 80px;
    background: var(--accent-golden, #eeae47);
    color: #1d2e2a;
    padding: 12px 20px;
    border-radius: 20px 20px 0 20px;
    font-size: 0.9rem;
    max-width: 280px;
    box-shadow: 0 4px 20px rgba(238, 174, 71, 0.4);
    animation: resiHintPulse 2s ease-in-out infinite;
    z-index: 8999;
    cursor: pointer;
}

.rh-resi-hint::after {
    content: '💬';
    position: absolute;
    bottom: -20px;
    right: 10px;
    font-size: 1.5rem;
}

@keyframes resiHintPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* ========== LOADING STATE ========== */
.rh-panel-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary, #c2c3c3);
}

.rh-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary, #18b090);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .rh-slide-panel {
        width: 85%;
    }
    
    .rh-panel-dock {
        right: 10px;
    }
    
    .rh-dock-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .rh-slide-panel {
        width: 100%;
    }
    
    .rh-panel-dock {
        bottom: 20px;
        right: 50%;
        top: auto;
        transform: translateX(50%);
        flex-direction: row;
    }
    
    .rh-dock-icon::before {
        right: auto;
        bottom: 60px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ========== DAY MODE OVERRIDES ========== */
body.day-mode .rh-slide-panel {
    background: #fffef5;
}

body.day-mode .rh-panel-overlay {
    background: rgba(0, 0, 0, 0.3);
}

body.day-mode .rh-module-card {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(24, 176, 144, 0.3);
}

body.day-mode .rh-dock-icon {
    background: #fffef5;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
