/* ==========================================================================
   TATTWA TIMER - MODERN GLASSMORPHIC DARK MODE STYLES
   ========================================================================== */

:root {
    /* Theme Colors */
    --bg-primary: #070a13;
    --bg-secondary: #0f1322;
    --bg-card: rgba(15, 20, 35, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    
    /* Text Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;
    
    /* UI Accent Colors */
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    
    /* Tattwa Element Colors & Glows */
    --color-akash: #a855f7;
    --bg-akash: rgba(168, 85, 247, 0.12);
    --glow-akash: rgba(168, 85, 247, 0.35);

    --color-vayu: #3b82f6;
    --bg-vayu: rgba(59, 130, 246, 0.12);
    --glow-vayu: rgba(59, 130, 246, 0.35);

    --color-tejas: #f43f5e;
    --bg-tejas: rgba(244, 63, 94, 0.12);
    --glow-tejas: rgba(244, 63, 94, 0.35);

    --color-apas: #06b6d4;
    --bg-apas: rgba(6, 182, 212, 0.12);
    --glow-apas: rgba(6, 182, 212, 0.35);

    --color-prithvi: #eab308;
    --bg-prithvi: rgba(234, 179, 8, 0.12);
    --glow-prithvi: rgba(234, 179, 8, 0.35);

    /* Fonts & Radii */
    --font-headings: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    padding: 24px 16px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

h1, h2, h3, h4 {
    font-family: var(--font-headings);
    font-weight: 600;
}

h1 {
    font-size: 1.75rem;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 500;
}

h3 {
    font-size: 1.1rem;
}

h4 {
    font-size: 0.95rem;
}

/* ==========================================================================
   CARDS & REUSABLE LAYOUTS
   ========================================================================== */

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
    transition: var(--transition-smooth);
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

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

.logo {
    height: 52px;
    width: auto;
    filter: drop-shadow(0 4px 12px rgba(79, 70, 229, 0.2));
}

.title-meta {
    display: flex;
    flex-direction: column;
}

.active-city-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 4px;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.active-city-badge::before {
    content: "📍";
    font-size: 0.7rem;
}

/* ==========================================================================
   CONTROLS CARD
   ========================================================================== */

.controls-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.date-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-arrow {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.nav-arrow:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.05);
}

.date-picker-wrapper {
    position: relative;
    flex-grow: 1;
    margin: 0 16px;
    max-width: 260px;
}

.date-picker-wrapper input[type="date"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    outline: none;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.date-picker-wrapper input[type="date"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* SEARCH & AUTOCOMPLETE */

.city-section {
    position: relative;
    width: 100%;
}

.search-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2px 8px;
    gap: 8px;
    transition: var(--transition-smooth);
}

.search-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.search-icon {
    font-size: 0.9rem;
    opacity: 0.5;
    margin-left: 6px;
}

#citySearch {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 10px 0;
}

.icon-button {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    opacity: 0.7;
}

.icon-button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.suggestions-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    list-style: none;
    z-index: 99;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    max-height: 240px;
    overflow-y: auto;
}

.suggestions-list li {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-smooth);
}

.suggestions-list li:last-child {
    border-bottom: none;
}

.suggestions-list li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
}

/* ==========================================================================
   TABS STYLING
   ========================================================================== */

.tabs-nav {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.tab-button {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-headings);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 10px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.tab-button:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.tab-button.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.tab-pane {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.tab-pane.active {
    display: flex;
}

/* ==========================================================================
   TAB 1: RELOJ (TIMER)
   ========================================================================== */

.current-tattwa-card {
    text-align: center;
    padding: 32px 24px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.current-tattwa-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    transition: var(--transition-smooth);
}

/* Glow classes loaded dynamically via JS */
.glow-active-akash {
    box-shadow: 0 0 35px -5px var(--glow-akash);
    border-color: rgba(168, 85, 247, 0.4);
}
.glow-active-vayu {
    box-shadow: 0 0 35px -5px var(--glow-vayu);
    border-color: rgba(59, 130, 246, 0.4);
}
.glow-active-tejas {
    box-shadow: 0 0 35px -5px var(--glow-tejas);
    border-color: rgba(244, 63, 94, 0.4);
}
.glow-active-apas {
    box-shadow: 0 0 35px -5px var(--glow-apas);
    border-color: rgba(6, 182, 212, 0.4);
}
.glow-active-prithvi {
    box-shadow: 0 0 35px -5px var(--glow-prithvi);
    border-color: rgba(234, 179, 8, 0.4);
}

.tattwa-name-display {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 16px 0;
    transition: var(--transition-smooth);
}

/* Dynamic element colors */
.color-akash { color: var(--color-akash) !important; }
.color-vayu { color: var(--color-vayu) !important; }
.color-tejas { color: var(--color-tejas) !important; }
.color-apas { color: var(--color-apas) !important; }
.color-prithvi { color: var(--color-prithvi) !important; }

.remaining-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.label-text {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.time-countdown {
    font-family: var(--font-headings);
    font-size: 1.35rem;
    font-weight: 700;
}

.progress-bar {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    overflow: hidden;
    height: 8px;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 20px;
    width: 0%;
    transition: width 1s linear, background-color 1s ease;
}

/* Next element styles */
.next-tattwa-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.next-tattwa-flex {
    display: flex;
    align-items: center;
    gap: 8px;
}

.next-element-display {
    font-family: var(--font-headings);
    font-size: 1.15rem;
    font-weight: 600;
}

/* ==========================================================================
   TAB 2: CRONOGRAMA (TIMELINE)
   ========================================================================== */

.timeline-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filters-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filters-container h4 {
    color: var(--text-muted);
}

.filters-container label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 14px;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
}

.filters-container input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

.table-card {
    padding: 0;
    overflow: hidden;
}

#tattwasTable {
    width: 100%;
    border-collapse: collapse;
}

#tattwasTable th, #tattwasTable td {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.9rem;
}

#tattwasTable th {
    background-color: rgba(255, 255, 255, 0.02);
    font-family: var(--font-headings);
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

#tattwasTable td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

#tattwasTable tbody tr:last-child td {
    border-bottom: none;
}

#tattwasTable tbody tr {
    transition: var(--transition-smooth);
}

#tattwasTable tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Table timeline dot badges */
.timeline-tattwa-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ==========================================================================
   TAB 3: BIBLIOTECA (LIBRARY)
   ========================================================================== */

.library-intro {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0 10px;
}

.library-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 480px) {
    .library-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.library-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    border-left-width: 4px;
}

.library-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.06);
}

.library-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tattwa-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-akash { background-color: var(--color-akash); box-shadow: 0 0 8px var(--color-akash); }
.dot-vayu { background-color: var(--color-vayu); box-shadow: 0 0 8px var(--color-vayu); }
.dot-tejas { background-color: var(--color-tejas); box-shadow: 0 0 8px var(--color-tejas); }
.dot-apas { background-color: var(--color-apas); box-shadow: 0 0 8px var(--color-apas); }
.dot-prithvi { background-color: var(--color-prithvi); box-shadow: 0 0 8px var(--color-prithvi); }

.border-akash { border-left-color: var(--color-akash); }
.border-vayu { border-left-color: var(--color-vayu); }
.border-tejas { border-left-color: var(--color-tejas); }
.border-apas { border-left-color: var(--color-apas); }
.border-prithvi { border-left-color: var(--color-prithvi); }

.library-card-subtitle {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.library-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.modern-button {
    background: var(--accent);
    color: white;
    border: none;
    font-family: var(--font-headings);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modern-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.modern-button.secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.modern-button.secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.modern-button.text-btn {
    background: transparent;
    color: var(--text-muted);
}

.modern-button.text-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.print-btn {
    align-self: stretch;
}

@media (min-width: 480px) {
    .print-btn {
        align-self: auto;
    }
}

/* ==========================================================================
   NATIVE DIALOG / MODAL STYLES
   ========================================================================== */

dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    color: var(--text-main);
    max-width: 90%;
    width: 480px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    outline: none;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

dialog[open] {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal opening transition fallback */
@keyframes modalFadeIn {
    from { opacity: 0; transform: translate(-50%, -45%) scale(0.96); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

dialog[open] {
    animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

dialog::backdrop {
    background-color: rgba(4, 7, 14, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

dialog[open]::backdrop {
    opacity: 1;
}

.dialog-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
}

.dialog-content.text-left {
    text-align: left;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 8px;
}

.close-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: var(--transition-smooth);
}

.close-icon-btn:hover {
    color: var(--text-main);
    transform: scale(1.1);
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

dialog textarea {
    width: 100%;
    height: 80px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 12px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    resize: none;
    transition: var(--transition-smooth);
}

dialog textarea:focus {
    border-color: var(--accent);
}

.highlight {
    color: var(--accent);
    font-weight: 600;
}

/* Custom styles for Tattwa detailed modal */
#tattwaInfoDialog {
    width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.tattwa-info-title {
    font-size: 1.5rem;
}

.tattwa-info-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 14px;
}

.info-section h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 4px;
}

.info-paragraph {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.45;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 480px) {
    .info-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.info-section ul {
    list-style-position: inside;
    list-style-type: none;
}

.info-section li {
    font-size: 0.85rem;
    margin-bottom: 6px;
    line-height: 1.4;
    position: relative;
    padding-left: 14px;
}

.info-section li::before {
    content: "•";
    position: absolute;
    left: 2px;
    color: var(--accent);
}

.positive-props li::before { color: var(--success); }
.negative-props li::before { color: var(--danger); }

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ==========================================================================
   PRINT MEDIA QUERIES
   ========================================================================== */

@media print {
    body {
        background: white !important;
        color: black !important;
        padding: 0 !important;
    }
    
    .app-container {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Hide non-print structures */
    .app-header,
    .controls-card,
    .tabs-nav,
    .tab-pane:not(#tab-timeline),
    .timeline-controls,
    dialog {
        display: none !important;
    }
    
    #tab-timeline {
        display: block !important;
    }
    
    .table-card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: transparent !important;
        backdrop-filter: none !important;
    }
    
    #tattwasTable {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    
    #tattwasTable th, #tattwasTable td {
        border: 1px solid #ddd !important;
        color: black !important;
        padding: 8px 12px !important;
        background: transparent !important;
    }
    
    .timeline-tattwa-badge {
        font-weight: bold !important;
    }
    
    .timeline-dot {
        border: 1px solid black !important;
    }
    
    /* Print Header block */
    .table-card::before {
        content: attr(data-print-title);
        display: block;
        font-family: var(--font-headings);
        font-size: 20pt;
        font-weight: bold;
        margin-bottom: 20px;
        text-align: center;
    }
    
    .table-card::after {
        content: attr(data-print-footer);
        display: block;
        font-size: 10pt;
        text-align: center;
        margin-top: 30px;
        border-top: 1px solid #ccc;
        padding-top: 10px;
    }
}
