/**
 * PLESI - Design System & Global Styles
 * Inspired by Ionic Framework & PLESI Identity
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Colors - Light Mode (Base: PLESI MIV) */
    --primary: #4F46E5;
    --primary-shade: #4338CA;
    --primary-tint: #6366F1;
    --secondary: #2DD4BF;
    --tertiary: #6366F1;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --dark: #0F172A;
    --medium: #64748B;
    --light: #F1F5F9;

    /* Semantic Colors */
    --background: #F8FAFC;
    --surface: #FFFFFF;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --border-color: #E2E8F0;
    --input-background: #FFFFFF;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --glass-background: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);

    /* Spacing & Borders */
    --border-radius: 12px;
    --border-radius-lg: 20px;
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --background: #0F172A;
    --surface: #1E293B;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --border-color: #334155;
    --input-background: #1E293B;
    --card-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --glass-background: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --light: #1E293B;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

/* Utility Classes */
.glass {
    background: var(--glass-background);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.ai-glow { box-shadow: 0 0 20px rgba(79, 70, 229, 0.2); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 20px; }
.label { display: block; margin-bottom: 8px; font-size: 0.875rem; font-weight: 600; color: var(--text-secondary); }
.input {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--border-radius);
    border: 1.5px solid var(--border-color);
    background-color: var(--input-background);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }

/* Alerts */
.alert {
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    font-weight: 600;
}
.alert-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-error { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }

/* Typography */
.welcome-title { font-size: 2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; }
.welcome-subtitle { font-size: 1rem; color: var(--text-secondary); }

/* Layout Structure */
.app-container { display: flex; min-height: 100vh; overflow: hidden; }
.main-content { flex: 1; padding: 24px 32px; margin-left: 280px; transition: all 0.3s; height: 100vh; overflow-y: auto; }

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
}

.user-greeting { font-weight: 500; color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1024px) {
    .main-content { margin-left: 0; padding: 20px; }
    .mobile-menu-btn { display: flex; }
    .user-greeting { font-size: 0.9rem; }
    .top-bar { margin-bottom: 24px; gap: 8px; }
}

/* Grid Forms */
.grid-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.full-width { grid-column: span 2; }

@media (max-width: 768px) {
    .grid-form { grid-template-columns: 1fr; }
    .full-width { grid-column: span 1; }
}

/* Glass Padding Utilities */
.glass-padding { padding: 32px; border-radius: 24px; }
@media (max-width: 768px) {
    .glass-padding { padding: 20px; }
    .welcome-title { font-size: 1.5rem; }
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border-right: 1px solid var(--border-color);
    background: var(--surface);
}

.sidebar-header { padding: 24px; display: flex; align-items: center; gap: 12px; }
.logo-box-sm {
    width: 36px; height: 36px; background: var(--primary); color: white;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.sidebar-title { font-size: 1.25rem; font-weight: 800; line-height: 1; }
.sidebar-brand { display: flex; flex-direction: column; gap: 2px; }
.sidebar-subtitle { font-size: 0.65rem; font-weight: 600; color: var(--text-secondary); opacity: 0.8; letter-spacing: -0.2px; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-section { padding: 16px 12px 8px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    color: var(--text-secondary); text-decoration: none; font-weight: 600;
    border-radius: 12px; margin-bottom: 4px; transition: all 0.2s;
}
.nav-item:hover { background: var(--light); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item.logout:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.sidebar-footer { 
    padding: 12px; 
    border-top: 1px solid var(--border-color); 
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.nav-item.logout { color: var(--danger); }
.nav-item.logout:hover { background: rgba(239, 68, 68, 0.1); }

/* Mobile Logout in Top Bar */
.mobile-logout-btn { display: none; }
@media (max-width: 1024px) {
    .mobile-logout-btn { 
        display: flex; align-items: center; justify-content: center;
        width: 44px; height: 44px; border-radius: 12px;
        background: rgba(239, 68, 68, 0.1); color: var(--danger);
        border: 1px solid rgba(239, 68, 68, 0.1); cursor: pointer;
    }
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    height: 56px;
    position: relative;
    z-index: 100;
}

.user-greeting {
    margin-right: auto;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.user-greeting strong { font-weight: 800; color: var(--primary); }

.theme-btn {
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    border-radius: 12px; background: var(--surface); border: 1px solid var(--border-color);
    color: var(--text-primary); cursor: pointer; transition: all 0.2s;
}

.mobile-menu-btn {
    display: none; background: var(--surface); border: 1px solid var(--border-color);
    padding: 10px; border-radius: 12px; cursor: pointer; color: var(--text-primary);
}

/* IA Processing Modal */
.ai-modal {
    display: flex; position: fixed; z-index: 3000; left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(8px);
    align-items: center; justify-content: center; text-align: center; color: white;
}
.ai-loader {
    width: 80px; height: 80px; border: 4px solid rgba(255,255,255,0.1);
    border-top: 4px solid var(--primary); border-radius: 50%;
    animation: spin 1s linear infinite; margin: 0 auto 24px;
    box-shadow: 0 0 30px rgba(79, 70, 229, 0.4);
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.ai-step-text { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; background: linear-gradient(to right, #fff, #94A3B8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.ai-sub-text { font-size: 0.9rem; opacity: 0.7; }

/* Strategic Table 5W2H */
.strategic-table-wrapper { overflow-x: auto; margin: 32px 0; border-radius: 16px; border: 1px solid var(--border-color); box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.strategic-table { width: 100%; border-collapse: collapse; background: var(--surface); table-layout: auto; }
.strategic-table th { background: var(--primary); color: white; padding: 12px 10px; text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.strategic-table td { padding: 12px 10px; border-bottom: 1px solid var(--border-color); font-size: 0.85rem; line-height: 1.4; vertical-align: top; }
.strategic-table tr:last-child td { border-bottom: none; }
.strategic-table tr:nth-child(even) { background: var(--light); }
.strategic-table td strong { color: var(--primary); display: block; margin-bottom: 4px; }

/* Study Content Markdown Styling */
.study-content h2 { color: var(--primary); font-size: 1.75rem; border-left: 5px solid var(--primary); padding-left: 16px; margin: 48px 0 24px; }
.study-content h3 { color: var(--text-primary); font-size: 1.25rem; margin: 32px 0 16px; font-weight: 800; }
.study-content p { margin-bottom: 20px; font-size: 1.05rem; }
.study-content ul { margin-bottom: 24px; list-style: none; }
.study-content li { margin-bottom: 12px; position: relative; padding-left: 28px; }
.study-content li::before { content: "→"; position: absolute; left: 0; color: var(--primary); font-weight: 800; }

/* Form Styles */
.form-section { margin-bottom: 40px; }
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--light); }
.section-number { width: 28px; height: 28px; background: var(--primary); color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 800; }
.section-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); text-transform: uppercase; }

.scale-container {
    display: flex;
    gap: 16px;
    background: var(--light);
    padding: 10px;
    border-radius: 18px;
    width: fit-content;
}

.scale-item {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    font-weight: 800;
    cursor: pointer;
    color: var(--text-secondary);
    border: none;
    background: var(--surface);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.scale-item:hover {
    transform: translateY(-2px);
    color: var(--primary);
}

.scale-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.3);
}

/* Profile specific */
.profile-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
}

@media (max-width: 768px) {
    .profile-grid { grid-template-columns: 1fr; }
}

.avatar-big {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary), var(--tertiary));
    color: white;
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 800;
    margin: 0 auto 20px;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.2);
}

textarea.input { min-height: 100px; resize: vertical; }
.input-currency { font-weight: 700; color: var(--primary); }

/* Dark Mode SVGs */
[data-theme="dark"] svg { stroke: #FFFFFF; }
[data-theme="dark"] .btn-primary svg, 
[data-theme="dark"] .logo-box svg, 
[data-theme="dark"] .logo-box-sm svg,
[data-theme="dark"] .nav-item.active svg { stroke: #FFFFFF; }

/* Mobile Responsive */
@media (max-width: 1024px) {
    .main-content { margin-left: 0; padding: 20px; }
    .mobile-menu-btn { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.open { transform: translateX(0); }
    .mobile-close { display: block; }
}
