/* Reset y variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #666;
    --sidebar-bg: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
    --border-color: #FFD70030;
    --card-shadow: 0 4px 6px rgba(0,0,0,0.1);
    --gold: #FFD700;
    --gold-dark: #FFA500;
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --sidebar-bg: linear-gradient(180deg, #0a0a15 0%, #05050a 100%);
    --border-color: #FFD70050;
    --card-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-header {
    text-align: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.gold-icon {
    font-size: 2rem;
    display: block;
    line-height: 1.2;
}

.sidebar-header h3 {
    color: #FFD700;
    margin-top: 10px;
}

/* Days Counter */
.days-counter {
    text-align: center;
    padding: 15px;
    margin: 0 15px 20px 15px;
    background: rgba(255,215,0,0.1);
    border-radius: 15px;
    border: 1px solid #FFD700;
}

.days-number {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: #FFD700;
}

.days-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0 15px;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 12px 20px;
    text-align: left;
    color: var(--text-secondary);
    font-size: 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: rgba(255,215,0,0.1);
    color: #FFD700;
}

.nav-btn.active {
    background: linear-gradient(90deg, #FFD70020, transparent);
    color: #FFD700;
    border-left: 3px solid #FFD700;
}

/* Enfoque accesible para teclado */
.nav-btn:focus-visible,
.btn-gold:focus-visible,
.theme-btn:focus-visible,
.logout-btn:focus-visible,
.add-meta input:focus-visible,
.notas-editor:focus-visible {
    outline: 2px solid #FFD700;
    outline-offset: 2px;
}

.sidebar-footer {
    padding: 20px 15px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

.theme-btn, .logout-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    font-size: 0.9rem;
}

.theme-btn {
    background: rgba(255,215,0,0.2);
    color: #FFD700;
}

.logout-btn {
    background: rgba(255,107,107,0.2);
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
}

.logout-btn:hover {
    background: #ff6b6b;
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    background: var(--bg-primary);
    min-width: 0;
}

.top-bar {
    background: var(--bg-secondary);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar h1 {
    color: #FFD700;
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-primary);
    padding: 8px 15px;
    border-radius: 20px;
    color: var(--text-primary);
}

.content-area {
    padding: 30px;
    overflow-y: auto;
}

/* Cards */
.welcome-card, .info-card {
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.info-card {
    margin-bottom: 0;
    border-top: 3px solid #FFD700;
}

.info-card h3 {
    color: #FFD700;
    margin-bottom: 15px;
}

.quote-box {
    background: linear-gradient(135deg, #FFD70020, #FFA50020);
    border-left: 4px solid #FFD700;
    padding: 20px;
    margin-top: 20px;
    font-style: italic;
    font-size: 1.1rem;
    border-radius: 10px;
}

/* Notas personales */
.notas-editor {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border: 2px solid #FFD700;
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
}

.notas-editor:focus {
    outline: none;
    border-color: #FFA500;
}

.save-status {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #4CAF50;
}

/* Metas */
.metas-list {
    list-style: none;
    padding: 0;
}

.meta-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 10px 0;
    background: var(--bg-primary);
    border-radius: 10px;
    gap: 15px;
    transition: background 0.2s;
    flex-wrap: wrap;
}

.meta-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #FFD700;
}

.meta-text {
    flex: 1;
    word-break: break-word;
}

.meta-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.add-meta {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.add-meta input {
    flex: 1;
    padding: 10px;
    border: 1px solid #FFD700;
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-width: 0;
}

/* Modales */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background: var(--bg-secondary);
    margin: 10% auto;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid #FFD700;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.close-modal:hover {
    color: #FFD700;
}

/* Botones */
.btn-gold {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1a1a2e;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-gold:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(255,215,0,0.4);
}

.btn-gold:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    border: 1px solid #FFD700;
    color: #FFD700;
}

.btn-secondary:hover {
    background: rgba(255,215,0,0.1);
}

a {
    color: #FFD700;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

hr {
    margin: 15px 0;
    border-color: var(--border-color);
}

/* ========================================= */
/* RESPONSIVE - MEDIA QUERIES MEJORADAS      */
/* ========================================= */

/* Tablets (768px - 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    .main-content {
        margin-left: 240px;
    }
    .content-area {
        padding: 20px;
    }
    .top-bar {
        padding: 15px 20px;
    }
    .top-bar h1 {
        font-size: 1.3rem;
    }
}

/* Móviles grandes y tablets pequeñas (≤768px) */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
        padding: 10px 0;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .sidebar-header {
        padding: 15px;
        margin-bottom: 10px;
    }
    
    .gold-icon {
        font-size: 1.8rem;
    }
    
    .sidebar-header h3 {
        font-size: 1.2rem;
    }
    
    .days-counter {
        margin: 0 10px 15px 10px;
        padding: 10px;
    }
    
    .days-number {
        font-size: 2rem;
    }
    
    .sidebar-nav {
        padding: 0 10px;
        gap: 3px;
    }
    
    .nav-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .sidebar-footer {
        padding: 15px 10px;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .top-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 12px 15px;
        position: relative;
    }
    
    .top-bar h1 {
        font-size: 1.2rem;
    }
    
    .user-info {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    .content-area {
        padding: 15px;
    }
    
    .welcome-card, .info-card {
        padding: 15px;
    }
    
    .welcome-card h2 {
        font-size: 1.3rem;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .info-card h3 {
        font-size: 1.1rem;
    }
    
    .quote-box {
        padding: 15px;
        font-size: 1rem;
    }
    
    .notas-editor {
        min-height: 200px;
        font-size: 0.9rem;
    }
    
    .meta-item {
        padding: 10px;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .meta-text {
        font-size: 0.9rem;
    }
    
    .meta-date {
        font-size: 0.7rem;
    }
    
    .add-meta {
        flex-direction: column;
        gap: 10px;
    }
    
    .add-meta input {
        width: 100%;
    }
    
    .add-meta button {
        width: 100%;
    }
    
    .btn-gold {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .modal-content {
        margin: 20% auto;
        width: 95%;
        padding: 20px;
    }
    
    .close-modal {
        top: 10px;
        right: 15px;
        font-size: 24px;
    }
}

/* Móviles pequeños (≤480px) */
@media (max-width: 480px) {
    .sidebar {
        max-height: 50vh;
    }
    
    .nav-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .days-number {
        font-size: 1.8rem;
    }
    
    .days-label {
        font-size: 0.7rem;
    }
    
    .content-area {
        padding: 10px;
    }
    
    .welcome-card, .info-card {
        padding: 12px;
    }
    
    .welcome-card h2 {
        font-size: 1.2rem;
    }
    
    .quote-box {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .notas-editor {
        min-height: 150px;
        font-size: 0.85rem;
    }
    
    .meta-item {
        padding: 8px;
        gap: 8px;
    }
    
    .meta-text {
        font-size: 0.85rem;
    }
    
    .btn-gold {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .theme-btn, .logout-btn {
        padding: 8px;
        font-size: 0.8rem;
    }
    
    .top-bar h1 {
        font-size: 1.1rem;
    }
    
    .user-info {
        font-size: 0.8rem;
    }
}

/* Orientación horizontal en móviles (landscape) */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        max-height: 45vh;
    }
    
    .content-area {
        padding: 10px;
    }
    
    .notas-editor {
        min-height: 120px;
    }
}

/* Pantallas muy grandes (≥1400px) */
@media (min-width: 1400px) {
    .sidebar {
        width: 320px;
    }
    
    .main-content {
        margin-left: 320px;
    }
    
    .content-area {
        padding: 40px;
    }
    
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 30px;
    }
    
    .welcome-card, .info-card {
        padding: 30px;
    }
    
    .top-bar h1 {
        font-size: 1.8rem;
    }
}