/* Global layout and structural styles */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 4rem 2rem 1rem 2rem; /* Increased top padding to account for header */
    position: relative;
}

/* Header controls container */
.header-controls {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: calc(100% - 2rem);
    max-width: 1000px;
    z-index: 1000;
}

/* Desktop layout: position elements in grid */
.left-buttons {
    justify-self: start;
    grid-column: 1;
    display: flex;
    gap: 0.5rem;
}

.app-title {
    justify-self: center;
    grid-column: 2;
}

.right-buttons {
    justify-self: end;
    grid-column: 3;
    display: flex;
    gap: 0.5rem;
}

.app-title {
    font-size: 2rem;
    margin: 0;
    color: var(--text-primary);
    font-weight: 400;
}

.screens-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    max-width: 100%;
}

.container {
    background: var(--bg-secondary);
    padding: 1rem;
    padding-top: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-heavy);
    max-width: 400px;
    min-width: 280px;
    width: 100%;
    position: relative;
}

.outputs-section {
    margin-top: 1rem;
}

.output-section-title {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    text-transform: uppercase;
}

.output-item {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.output-item:last-child,
.output-item.no-margin {
    margin-bottom: 0;
}

.output-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.output-value {
    font-weight: bold;
    color: var(--text-primary);
}

.output-unit {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-left: 0.25rem;
}

.output-separator {
    height: 1px;
    background-color: var(--border-primary);
    margin: 0.4rem 0;
}

footer {
    margin-top: auto;
    padding-top: 3rem;
    padding-bottom: 1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    width: 100%;
}

/* Responsive design */
@media (max-width: 1040px) {
    .header-controls {
        width: calc(100% - 2rem);
        left: 50%;
        transform: translateX(-50%);
    }
    
    .reset-button {
        right: 1rem;
    }
}

@media (max-width: 600px) {
    body {
        padding-top: 7rem; /* More space for stacked header with buttons above */
    }
    
    .header-controls {
        display: flex; /* Override grid layout for mobile */
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0rem 1rem;
    }
    
    /* Reset desktop grid positioning for mobile */
    .left-buttons,
    .app-title,
    .right-buttons {
        justify-self: auto;
        grid-column: auto;
    }
    
    .left-buttons,
    .right-buttons {
        display: contents; /* Make children appear as direct children of header-controls */
    }
    
    /* Put the title on the first row */
    .app-title {
        order: 1;
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    /* Put all buttons on the second row */
    .theme-toggle {
        order: 2;
    }
    
    .unit-toggle {
        order: 3;
    }
    
    .info-button {
        order: 4;
    }
    
    .copy-url-button {
        order: 5;
    }
    
    .reset-button {
        order: 6;
    }
}

@media (max-width: 600px) {
    /* .app-title { 
        font-size: 1.5rem; 
    } */
    
    h1 { 
        font-size: 1.8rem; 
    }
}
