/* ========================================
   RESPONSIVE
   ======================================== */

/* Tablet (max-width: 1024px) */
@media (max-width: 1024px) {
    body {
        padding: 0.5rem;
    }

    .biggest-container {
        padding: 0.5rem;
    }

    .btn,
    .menu-btn,
    .control-btn,
    .filter-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    :root {
        --font-size-base: 1.125rem;
        --font-size-sm: 1rem;
        --font-size-lg: 1.375rem;
        --font-size-xl: 1.625rem;
        --font-size-2xl: 2.25rem;
    }

    body {
        padding: 0;
        padding-bottom: 5.5rem;
    }

    .biggest-container {
        padding: 0.5rem;
        padding-bottom: 6rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Layout Overrides */
    .mobile-header {
        display: block;
    }

    .title-container {
        display: none !important;
    }

    .menu-toggle {
        display: none !important;
    }

    .full-view-header {
        display: block;
    }

    /* Side Menu & Toggle */
    .side-menu {
        display: none;
    }

    /* Containers */
    .big-container {
        flex-direction: column;
        gap: 1.5rem;
        padding: 0;
    }

    .timetable-wrapper {
        order: 1;
        width: 100%;
        border-radius: var(--border-radius-xs);
        margin: 0;
        box-shadow: 0 4px 12px var(--shadow-color);
        margin-top: 0;
        margin-bottom: 2rem;
    }

    .timetable {
        border-radius: 0;
    }

    .timetable th,
    .timetable td {
        padding: 0.75rem;
        font-size: var(--font-size-lg);
        /* Larger font */
        width: 50rem;

    }

    #emojis {
        font-size: var(--font-size-xl);
    }

    /* Increased from previous small size */

    canvas {
        display: none;
    }

    #scroll-indicator-bg,
    #scroll-indicator {
        display: none;
    }

    #time {
        font-size: clamp(4rem, 15vw, 8rem);
    }

    #date {
        font-size: clamp(1.3rem, 4vw, 2rem);
    }

    #infoOverlay {
        padding: 0;
    }

    .info-overlay-container {
        width: 100vw;
        max-width: 100%;
        height: 100dvh;
        max-height: 100%;
        border-radius: 0;
        padding: 1.5rem;
        padding-top: 4rem;
        overflow-y: auto;
    }

    .info-overlay-header h2 {
        font-size: var(--font-size-2xl);
        padding-right: 0;
    }

    .release-notes-section>h2 {
        font-size: var(--font-size-xl);
        flex-direction: column;
        gap: 0.5rem;
    }

    .release-note {
        padding: 1.25rem;
    }

    .release-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .release-version {
        font-size: var(--font-size-sm);
        padding: 0.35rem 0.85rem;
    }

    .release-date {
        font-size: var(--font-size-sm);
    }

    .release-note h4 {
        font-size: 1.15rem;
    }

    .release-note li {
        font-size: var(--font-size-sm);
    }

    /* Customization Mobile - Full Screen */
    .customization-container {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        flex-direction: column;
        /* Column layout for ordering */
        background: var(--bg-color);
        display: flex;
    }

    /* 
       Order 1: Content (Top)
       Order 2: Sidebar (Bottom)
    */

    .custom-content {
        flex: 1;
        order: 1;
        width: 100%;
        padding: 1.5rem 1rem;
        padding-top: 4rem;
        /* Space for close btn */
        padding-bottom: 1rem;
        overflow-y: auto;
        height: auto;
        max-height: none;
    }

    .custom-sidebar {
        order: 2;
        width: 100%;
        height: auto;
        min-height: 4.5rem;
        border-right: none;
        border-bottom: none;
        border-top: 1px solid var(--border-color);
        background: color-mix(in srgb, var(--card-bg) 95%, transparent);
        backdrop-filter: blur(var(--overlay-blur));
        -webkit-backdrop-filter: blur(var(--overlay-blur));
        overflow: visible;
        /* Allow overrides */
        z-index: 20;
        padding: 0;
        display: block;
        /* Let inner items flex */
        box-shadow: 0 -4px 20px var(--shadow-color);
        flex-shrink: 0;
    }

    .sidebar-header {
        display: none;
    }

    /* Target OverlayScrollbars structure if present, or direct child */
    .custom-sidebar .os-viewport,
    .custom-sidebar .os-content,
    .custom-sidebar {
        height: 10% !important;
        overflow: visible !important;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
        justify-content: space-evenly;
        align-items: center;
    }

    .sidebar-item {
        flex: 1;
        height: 4.5rem;
        padding: 0.25rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        border: none;
        background: transparent;
        color: var(--text-muted);
        transition: all 0.2s ease;
        border-radius: 0;
    }

    .sidebar-item i {
        font-size: var(--font-size-lg);
        margin: 0;
        width: auto;
        color: inherit;
    }

    .sidebar-item span {
        font-size: var(--font-size-xs);
        font-weight: 500;
        letter-spacing: 0.3px;
    }

    .sidebar-item.active {
        background: transparent;
        border: none;
        color: var(--accent-color);
        box-shadow: inset 0 -3px 0 0 var(--accent-color);
        /* Bottom border indicator */
    }

    .sidebar-item.active i {
        transform: scale(1.1);
        color: var(--accent-color);
    }

    /* Other Styles */
    .theme-section-hero {
        grid-template-columns: 1fr;
        align-items: stretch;
        padding: 1rem;
    }

    .theme-hero-stats {
        min-width: 0;
    }

    .theme-search-shell {
        padding: 0.8rem 0.9rem;
    }

    .theme-tags {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        padding-bottom: 0.35rem;
    }

    .theme-options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .theme-card {
        padding: 0.9rem;
    }

    .theme-card-preview {
        height: 92px;
    }

    .theme-card-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .theme-icon {
        font-size: 1.35rem;
    }

    .color-picker-wrapper {
        gap: 0.75rem;
        flex-direction: column;
        align-items: stretch;
    }

    .color-input-box {
        width: 50px;
        height: 50px;
    }

    .color-hex-input {
        width: 100%;
        font-size: var(--font-size-sm);
    }

    .color-presets-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 0.75rem;
    }

    .preset-item {
        width: 50px;
        height: 50px;
    }

    .preset-delete {
        width: 22px;
        height: 22px;
        font-size: var(--font-size-xs);
        top: -6px;
        right: -6px;
    }

    .font-select {
        padding: 0.75rem;
        font-size: var(--font-size-sm);
    }

    .presets-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .preset-action-btn {
        width: 100%;
        justify-content: center;
    }

    .saved-presets {
        grid-template-columns: 1fr;
    }

    .contrast-warning {
        font-size: var(--font-size-sm);
        padding: 0.85rem 1rem;
    }

    .add-custom-font-btn {
        padding: 1rem 1.5rem;
        font-size: var(--font-size-lg);
    }

    .custom-select-wrapper .select-arrow {
        right: 0.75rem;
    }

    .randomize-btn {
        width: 100%;
        margin-top: 0.5rem;
        margin-left: 0;
    }

    .add-preset-btn {
        width: 100%;
        justify-content: center;
    }

    /* Weather Mobile - Strict Full Screen */
    #weatherOverlay {
        padding: 0 !important;
        align-items: flex-start !important;
    }

    .weather-overlay-container {
        width: 100vw;
        max-width: 100%;
        height: 100dvh;
        max-height: 100%;
        border-radius: 0;
        padding: 1.5rem;
        padding-top: 4rem;
        position: fixed;
        inset: 0;
        margin: 0;
    }

    .weather-overlay-header h2 {
        font-size: var(--font-size-xl);
        flex-direction: column;
        gap: 0.5rem;
        padding-right: 0;
    }

    .weather-main-info {
        padding: 1.5rem;
    }

    .weather-large-emoji {
        font-size: 5rem;
    }

    .weather-large-temp {
        font-size: 2.5rem;
    }

    .weather-large-desc {
        font-size: var(--font-size-lg);
    }

    .weather-details-grid {
        grid-template-columns: 1fr;
    }

    .weather-detail-card {
        padding: 1.25rem;
    }

    .weather-detail-card i {
        font-size: 1.8rem;
    }

    .weather-detail-value {
        font-size: 1.2rem;
    }

    .weather-location-info {
        font-size: var(--font-size-lg);
    }

    .menu-weather-emoji {
        font-size: 1.6rem;
    }

    .menu-weather-temp {
        font-size: 1rem;
    }

    .weather-btn-content {
        gap: 0.75rem;
        background: var(--card-bg) !important;
    }

    .weather-btn-label {
        font-size: var(--font-size-xs);
    }

    .color-presets {
        gap: 0.5rem;
    }

    .color-presets .preset {
        width: 45px;
        height: 45px;
    }

    /* Todo Mobile - Full Screen */
    .advanced-todo-container {
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
        flex-direction: column;
    }

    .todo-sidebar {
        width: 100%;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        overflow-y: visible;
        margin-top: 4rem;
    }

    .todo-sidebar.collapsed {
        height: 60px;
    }

    .todo-sidebar.collapsed .todo-stats-compact,
    .todo-sidebar.collapsed .sidebar-section {
        display: none;
    }

    .sidebar-header {
        padding: 1rem 1.5rem;
    }

    .todo-stats-compact {
        padding: 0.75rem 1rem;
        gap: 0.35rem;
    }

    .stat-compact {
        padding: 0.5rem 0.25rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: var(--font-size-xs);
    }

    .sidebar-section {
        padding: 0.75rem 1rem;
    }

    .todo-content-header {
        padding: 1rem 1.5rem;
        flex-direction: column;
        align-items: stretch;
        margin-top: 0;
    }

    .close-btn-todo {
        top: 1rem;
        right: 1rem;
    }

    .header-left {
        order: 1;
    }

    .header-left h1 {
        font-size: 1.5rem;
    }

    .header-actions {
        order: 2;
        flex-direction: column;
        width: 100%;
    }

    .search-container,
    .view-switcher,
    .dropdown-container,
    .add-task-btn {
        width: 100%;
    }

    #taskSearch {
        width: 100%;
    }

    #taskSearch:focus {
        width: 100%;
    }

    .view-switcher {
        justify-content: center;
    }

    .list-view,
    .calendar-view {
        padding: 1rem;
    }

    .task-edit-container,
    .folder-edit-container {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding-top: 4rem;
    }

    .task-edit-content,
    .folder-edit-content {
        padding: 1rem 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .priority-flags {
        flex-wrap: wrap;
    }

    .priority-flag {
        flex: 1;
        min-width: 60px;
    }

    .color-picker-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .icon-picker-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .calendar-grid {
        gap: 0.5rem;
    }

    .calendar-day {
        min-height: 60px;
        padding: 0.35rem;
    }

    .calendar-day-number {
        font-size: var(--font-size-xs);
    }

    .task-edit-footer,
    .folder-edit-footer {
        flex-direction: column-reverse;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .task-item {
        padding: 1rem;
    }

    .folder-item {
        padding: 0.5rem 0.65rem;
    }

    .quick-filter {
        font-size: var(--font-size-sm);
        padding: 0.5rem 0.65rem;
    }

    .bottom-navbar {
        display: flex;
    }
}

/* Tablet (Landscape) */
@media (max-width: 768px) and (orientation: landscape) {
    .side-menu {
        width: 50%;
        max-width: 400px;
    }

    .task-modal-content {
        width: 90%;
        max-width: 700px;
        height: 90%;
        max-height: 90vh;
        border-radius: var(--border-radius);
    }

    .weather-overlay-container {
        width: 90%;
        max-width: 700px;
        height: 90%;
        max-height: 90vh;
        border-radius: var(--border-radius);
    }

    .weather-details-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    .title-container,
    .main-title,
    .time-display {
        animation: none;
    }

    .main-title::before {
        animation: none;
    }

    .time-display::after {
        display: none;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch Devices */
@media (hover: none) and (pointer: coarse) {

    .btn:active,
    .menu-btn:active,
    .control-btn:active,
    .filter-btn:active,
    .modal-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* Safe Area Insets */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0.5rem, env(safe-area-inset-left));
        padding-right: max(0.5rem, env(safe-area-inset-right));
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }

    .side-menu {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .menu-toggle {
        left: max(1rem, env(safe-area-inset-left));
        top: max(1rem, env(safe-area-inset-top));
    }
}

/* Small Mobile (max-width: 480px) specific tweaks */
@media (max-width: 480px) {
    #emojis {
        font-size: var(--font-size-xl);
    }

    .menu-toggle {
        border-radius: var(--border-radius);
    }

    .filter-btn {
        font-size: var(--font-size-xs);
        padding: 0.5rem 0.8rem;
    }
}
