/* Base responsive styles */
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-background);
    color: var(--md-on-background);
}

/* Container organization */
.container {
    position: relative; /* Create stacking context */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    text-align: center;
    width: 90%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 0;
    box-sizing: border-box;
    gap: clamp(1rem, 3vh, 2rem);
}

/* Logo responsiveness */
#site-logo {
    width: min(200px, 30vw);
    height: auto;
    margin-bottom: clamp(1rem, 4vh, 2rem);
}

/* Clock responsiveness */
.clock {
    font-size: clamp(2.5rem, 8vw, 6rem);
    font-weight: var(--md-font-weight-light);
    margin-bottom: clamp(1rem, 3vh, 2rem);
    line-height: 1.1;
}

/* Greeting panel adjustments */
.greeting {
    position: relative;
    z-index: 1;
    width: 100%;
    font-size: clamp(1rem, 4vw, var(--md-title-large-size));
    margin-bottom: clamp(1rem, 3vh, 2rem);
    padding: 0.5rem;
    font-weight: var(--md-font-weight-medium);
    color: var(--md-tertiary);
}

/* Search bar prioritization */
.search-bar {
    position: relative;
    z-index: 2; /* Ensure search bar stays above greeting */
    width: 100%;
    max-width: 600px;
    display: flex;
    border-radius: var(--md-shape-medium);
    overflow: hidden;
    order: 1; /* Move search bar up in flex order */
    box-shadow: var(--md-elevation-2);
    margin: 0; /* Remove margin, using gap instead */
    background-color: var(--md-surface-2);
    transition: box-shadow var(--md-transition-standard);
}

/* Ensure search input and button stay on top */
#search-input,
#search-button {
    position: relative;
    z-index: 2;
}

#search-input {
    flex: 1;
    min-width: 0;
    padding: clamp(0.8rem, 2vw, 1.2rem);
    font-size: clamp(0.9rem, 2vw, var(--md-body-large-size));
    font-family: 'Roboto', sans-serif;
    background-color: transparent;
    color: var(--md-on-surface);
}

#search-input::placeholder {
    opacity: 1;
    transition: opacity 0.2s;
    color: var(--md-on-surface-variant);
}

#search-button {
    padding: clamp(0.8rem, 2vw, 1.2rem) clamp(1rem, 3vw, 1.5rem);
    font-size: clamp(0.9rem, 2vw, var(--md-label-large-size));
    white-space: nowrap;
    background-color: var(--md-primary);
    color: var(--md-on-primary);
    font-family: 'Roboto', sans-serif;
    font-weight: var(--md-font-weight-medium);
}

/* Cursor effect for the typing animation */
@keyframes blink-cursor {
    0%, 100% { border-right-color: transparent; }
    50% { border-right-color: var(--md-on-surface-variant); }
}

.typing-animation::placeholder {
    border-right: 2px solid;
    animation: blink-cursor 1s infinite;
    padding-right: 1px; /* Small padding to make the cursor more visible */
}

/* Speed dial de-prioritization */
.speed-dial {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: clamp(0.8rem, 2vh, 1.5rem);
    order: 2; /* Move speed dial down in flex order */
    margin: 0; /* Remove margin, using gap instead */
}

.speed-dial-row {
    display: flex;
    justify-content: center;
    gap: clamp(0.8rem, 2vw, 1.5rem);
}

.speed-dial-button {
    flex: 1;
    max-width: 200px;
    padding: clamp(0.8rem, 2vh, 1.2rem);
    font-size: clamp(0.9rem, 2vw, var(--md-label-large-size));
    background-color: var(--md-surface-2);
    color: var(--md-on-surface);
    border-radius: var(--md-shape-medium);
    box-shadow: var(--md-elevation-1);
    font-family: 'Roboto', sans-serif;
    font-weight: var(--md-font-weight-medium);
    transition: all var(--md-transition-emphasized);
}

/* Weather widget responsiveness */
.weather-container {
    position: fixed;
    top: 1rem;
    left: 1rem;
}

#weather-widget {
    font-size: clamp(0.8rem, 2vw, var(--md-body-medium-size));
    padding: clamp(0.8rem, 2vw, 1.2rem);
    background-color: var(--md-surface-2);
    border-radius: var(--md-shape-medium);
    box-shadow: var(--md-elevation-2);
}

.weather-temp {
    font-size: clamp(1.2rem, 3vw, var(--md-title-large-size));
    color: var(--md-primary);
    font-weight: var(--md-font-weight-medium);
}

/* Settings panel responsiveness */
.settings-btn {
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    background-color: var(--md-surface-3);
    border-radius: 50%;
    box-shadow: var(--md-elevation-1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--md-transition-standard);
}

.settings-panel {
    width: min(400px, 85%);
}

.settings-header h2 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
}

.settings-group label {
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.settings-input, .settings-select {
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Import/Export controls */
.import-export-controls {
    display: flex;
    gap: clamp(0.8rem, 2vw, 1.5rem);
    justify-content: center;
    margin-top: 1rem;
}

#export-settings, #import-settings {
    padding: clamp(0.8rem, 2vw, 1.2rem);
    font-size: clamp(0.9rem, 2vw, var(--md-label-large-size));
    border-radius: var(--md-shape-medium);
    font-family: 'Roboto', sans-serif;
    font-weight: var(--md-font-weight-medium);
    transition: all var(--md-transition-standard);
    flex: 1;
    max-width: 200px;
}

/* Responsive breakpoints */
@media (max-width: 768px) {
    .container {
        padding: 1rem 0;
    }

    .weather-container {
        position: static;
        width: 100%;
        display: flex;
        justify-content: center;
        margin-bottom: 1rem;
    }

    #weather-widget {
        width: fit-content;
    }

    .speed-dial-row {
        flex-wrap: wrap;
    }

    .speed-dial-button {
        min-width: 120px;
    }

    .settings-panel {
        width: 100%;
    }

    .settings-categories {
        padding: 0.8rem;
    }

    .settings-section {
        padding: 1rem;
    }

    .import-export-controls {
        flex-direction: column;
        align-items: center;
    }

    #export-settings, #import-settings {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .container {
        width: 100%;
        padding: max(0.8rem, env(safe-area-inset-top)) 1rem 1rem;
        gap: 0.8rem;
    }

    /* Hide clock and greeting on small screens */
    .clock, .greeting {
        display: none;
    }

    /* Reduce logo spacing on small screens */
    #site-logo {
        margin-bottom: 0.5rem;
        width: min(150px, 25vw); /* Also make the logo a bit smaller */
    }

    .search-bar {
        margin-top: 0.5rem; /* Reduced from 1rem since we have less content above */
        flex-direction: column;
        padding: 0.5rem;
        margin: 0.5rem 0;
    }

    #search-input {
        text-align: left;
        padding: 0.8rem 1rem;
        margin-bottom: 0.5rem;
        border-radius: var(--md-shape-small);
    }

    #search-button {
        padding: 0.8rem;
        border-radius: var(--md-shape-small);
    }

    /* Minimize speed dial */
    .speed-dial {
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .speed-dial-row {
        gap: 0.5rem;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
    }

    .speed-dial-button {
        padding: 0.5rem;
        font-size: var(--md-label-small-size);
        min-height: 0;
        max-width: none;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--md-shape-small);
    }

    /* Ensure proper spacing after search */
    .speed-dial {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
    }

    .settings-categories {
        flex-wrap: wrap;
        justify-content: center;
    }

    .category-btn {
        width: 100%;
        justify-content: center;
    }
    
    .import-export-controls {
        padding: 0.5rem;
    }
    
    #export-settings, #import-settings {
        padding: 0.6rem;
        font-size: var(--md-label-medium-size);
    }
}

/* Add a breakpoint specifically for showing/hiding greeting */
@media (min-height: 600px) and (min-width: 480px) {
    .greeting {
        display: block;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-input::placeholder {
        color: var(--md-on-surface-variant);
        opacity: 0.7;
    }
}