/**
 * TERYT Street Finder - Fullscreen Material Design CSS
 * Wersja pełnoekranowa bez marginesów
 */

:root {
    /* Material Design Colors */
    --md-primary: #1976d2;
    --md-primary-dark: #1565c0;
    --md-primary-light: #42a5f5;
    --md-accent: #00acc1;
    --md-accent-dark: #00838f;

    /* Surfaces */
    --md-background: #fafafa;
    --md-surface: #ffffff;
    --md-surface-variant: #f5f5f5;
    --md-outline: #e0e0e0;
    --md-outline-variant: #eeeeee;

    /* Text colors */
    --md-on-surface: #212121;
    --md-on-surface-variant: #424242;
    --md-on-surface-disabled: #9e9e9e;

    /* Status colors */
    --md-success: #2e7d32;
    --md-success-light: #e8f5e8;
    --md-warning: #f57c00;
    --md-warning-light: #fff3e0;
    --md-error: #d32f2f;
    --md-error-light: #ffebee;
    --md-info: #1976d2;
    --md-info-light: #e3f2fd;

    /* Shadows */
    --md-shadow-1dp: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --md-shadow-2dp: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --md-shadow-4dp: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
    --md-shadow-8dp: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);

    /* Typography */
    --md-font-family: 'Roboto', 'Helvetica Neue', sans-serif;
    --md-font-size-h1: 2.125rem;
    --md-font-size-h2: 1.5rem;
    --md-font-size-h3: 1.25rem;
    --md-font-size-body: 0.875rem;
    --md-font-size-caption: 0.75rem;

    /* Spacing */
    --md-spacing-xs: 4px;
    --md-spacing-sm: 8px;
    --md-spacing-md: 16px;
    --md-spacing-lg: 24px;
    --md-spacing-xl: 32px;
    --md-spacing-xxl: 48px;

    /* Border radius */
    --md-radius-sm: 0px;
    --md-radius-md: 0px;
    --md-radius-lg: 0px;
}

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

body {
    font-family: var(--md-font-family);
    font-size: var(--md-font-size-body);
    line-height: 1.5;
    color: var(--md-on-surface);
    background-color: var(--md-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* =============================================================================
   HEADER - FULLSCREEN
   ============================================================================= */

.header {
    background: linear-gradient(135deg, var(--md-primary) 0%, var(--md-primary-dark) 100%);
    color: white;
    padding: var(--md-spacing-lg);
    position: relative;
    width: 100%;
    box-shadow: var(--md-shadow-2dp);
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="20" cy="20" r="1" fill="white" opacity="0.03"/><circle cx="80" cy="40" r="1" fill="white" opacity="0.02"/><circle cx="40" cy="80" r="1" fill="white" opacity="0.03"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>') repeat;
    pointer-events: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--md-spacing-xl);
    position: relative;
    z-index: 1;
    width: 100%;
}

.header-text {
    flex: 1;
    min-width: 0;
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: var(--md-spacing-xs);
}

.header-text p {
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 400;
}

.header-search {
    flex: 0 0 400px;
    max-width: 400px;
}

.connection-status {
    position: absolute;
    top: var(--md-spacing-sm);
    right: var(--md-spacing-sm);
    font-size: 0.75rem;
    opacity: 0.9;
    z-index: 2;
}

/* =============================================================================
   LEGENDA - PEŁNA SZEROKOŚĆ
   ============================================================================= */

.legend-bar {
    background: white;
    border-bottom: 1px solid var(--md-outline-variant);
    padding: var(--md-spacing-md) var(--md-spacing-lg);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--md-spacing-xl);
    flex-wrap: wrap;
    box-shadow: var(--md-shadow-1dp);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--md-spacing-sm);
    font-size: 0.875rem;
    white-space: nowrap;
}

.legend-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.legend-error .legend-icon {
    color: var(--md-error);
}

.legend-warning .legend-icon {
    color: var(--md-warning);
}

.legend-success .legend-icon {
    color: var(--md-success);
}

/* =============================================================================
   ZAWARTOŚĆ - PEŁNA SZEROKOŚĆ
   ============================================================================= */

.content {
    padding: var(--md-spacing-lg);
    width: 100%;
    background: var(--md-background);
    min-height: calc(100vh - 200px);
}

/* =============================================================================
   WYSZUKIWANIE GMIN
   ============================================================================= */

.gmina-search-container {
    position: relative;
    width: 100%;
}

.gmina-search-input {
    width: 100%;
    padding: var(--md-spacing-md);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: var(--md-radius-sm);
    font-size: 0.875rem;
    font-family: var(--md-font-family);
    background: white;
    color: var(--md-primary-dark);
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.gmina-search-input::placeholder {
    color: var(--md-on-surface-disabled);
}

.gmina-search-input:focus {
    background: white;
    border-color: var(--md-primary-light);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

.gmina-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--md-surface);
    border-radius: var(--md-radius-sm);
    box-shadow: var(--md-shadow-4dp);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    border: 1px solid var(--md-outline-variant);
}

.gmina-item {
    padding: var(--md-spacing-md);
    cursor: pointer;
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid var(--md-outline-variant);
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--md-primary-dark);
    background: white;
}

.gmina-item:last-child {
    border-bottom: none;
}

.gmina-item:hover,
.gmina-item.selected {
    background-color: rgba(25, 118, 210, 0.08);
}

.selected-gmina {
    background: rgba(255,255,255,0.2);
    padding: var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    border: 1px solid rgba(255,255,255,0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--md-spacing-md);
}

.selected-gmina .gmina-name {
    font-weight: 500;
    color: white;
    font-size: 0.875rem;
    flex: 1;
}

.selected-gmina .change-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: var(--md-spacing-sm) var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.selected-gmina .change-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

/* =============================================================================
   FORMULARZE I POLA
   ============================================================================= */

label {
    display: block;
    margin-bottom: var(--md-spacing-sm);
    font-weight: 500;
    color: var(--md-on-surface);
    font-size: 0.875rem;
}

input[type="text"],
select {
    width: 100%;
    padding: var(--md-spacing-md);
    border: 1px solid var(--md-outline);
    border-radius: var(--md-radius-sm);
    font-size: 1rem;
    font-family: var(--md-font-family);
    background: var(--md-surface);
    color: var(--md-on-surface);
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.12);
}

/* =============================================================================
   WPROWADZANIE ULIC
   ============================================================================= */

.ulice-input {
    margin-bottom: var(--md-spacing-xl);
    background: white;
    padding: var(--md-spacing-lg);
    border-radius: var(--md-radius-sm);
    box-shadow: var(--md-shadow-1dp);
}

.ulice-input textarea {
    width: 100%;
    padding: var(--md-spacing-md);
    border: 1px solid var(--md-outline);
    border-radius: var(--md-radius-sm);
    font-size: 1rem;
    font-family: var(--md-font-family);
    background: var(--md-surface);
    color: var(--md-on-surface);
    resize: vertical;
    min-height: 200px;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    line-height: 1.5;
}

.ulice-input textarea:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.12);
}

.ulice-input textarea::placeholder {
    color: var(--md-on-surface-disabled);
}

.instruction {
    background: var(--md-info-light);
    border: 1px solid rgba(25, 118, 210, 0.2);
    padding: var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    margin-bottom: var(--md-spacing-md);
    border-left: 4px solid var(--md-primary);
    line-height: 1.6;
    font-size: 0.875rem;
}

/* =============================================================================
   PRZYCISKI
   ============================================================================= */

.search-button {
    background: var(--md-primary);
    color: white;
    border: none;
    padding: var(--md-spacing-md) var(--md-spacing-lg);
    border-radius: var(--md-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--md-font-family);
    cursor: pointer;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--md-shadow-1dp);
    min-height: 40px;
    width: 100%;
}

.search-button:hover {
    background: var(--md-primary-dark);
    box-shadow: var(--md-shadow-2dp);
}

.search-button:active {
    box-shadow: var(--md-shadow-4dp);
}

.search-button:disabled {
    background: var(--md-on-surface-disabled);
    cursor: not-allowed;
    box-shadow: none;
}

.test-button {
    background: var(--md-accent);
    color: white;
    border: none;
    padding: var(--md-spacing-sm) var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    cursor: pointer;
    margin: var(--md-spacing-xs);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--md-shadow-1dp);
}

.test-button:hover {
    background: var(--md-accent-dark);
    box-shadow: var(--md-shadow-2dp);
}

/* =============================================================================
   LOADING I PROGRESS
   ============================================================================= */

.loading {
    display: none;
    text-align: center;
    padding: var(--md-spacing-xl);
    color: var(--md-on-surface-variant);
    background: white;
    border-radius: var(--md-radius-sm);
    margin-bottom: var(--md-spacing-md);
}

.spinner {
    border: 3px solid var(--md-outline-variant);
    border-top: 3px solid var(--md-primary);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--md-spacing-md);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--md-outline-variant);
    border-radius: 2px;
    overflow: hidden;
    margin: var(--md-spacing-md) 0;
}

.progress-fill {
    height: 100%;
    background: var(--md-primary);
    transition: width 200ms cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

/* =============================================================================
   WYNIKI I STATYSTYKI
   ============================================================================= */

.results {
    margin-top: var(--md-spacing-lg);
}

.stats {
    background: white;
    border: 1px solid var(--md-outline-variant);
    padding: var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    margin-bottom: var(--md-spacing-md);
    text-align: center;
    color: var(--md-on-surface-variant);
    line-height: 1.4;
    font-size: 0.875rem;
    box-shadow: var(--md-shadow-1dp);
}

.result-item {
    padding: var(--md-spacing-md);
    margin-bottom: var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    border-left: 4px solid;
    font-weight: 400;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--md-surface);
    box-shadow: var(--md-shadow-1dp);
    font-size: 0.875rem;
}

.result-found {
    background: var(--md-error-light);
    border-color: var(--md-error);
    color: var(--md-error);
    border: 1px solid rgba(211, 47, 47, 0.2);
}

.result-similar {
    background: var(--md-warning-light);
    border-color: var(--md-warning);
    color: var(--md-warning);
    border: 1px solid rgba(245, 124, 0, 0.2);
}

.result-not-found {
    background: var(--md-success-light);
    border-color: var(--md-success);
    color: var(--md-success);
    border: 1px solid rgba(46, 125, 50, 0.2);
}

.variant-info {
    margin-top: var(--md-spacing-sm);
    font-size: 0.75rem;
    opacity: 0.8;
    line-height: 1.4;
}

/* =============================================================================
   MIEJSCOWOŚCI
   ============================================================================= */

.locations-list {
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.3);
    padding: var(--md-spacing-sm);
    border-radius: var(--md-radius-sm);
    margin-top: var(--md-spacing-xs);
    font-size: 0.75rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.locations-count {
    font-weight: 500;
}

.locations-list-long {
    max-height: 100px;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,0.4);
}

.locations-list-long::-webkit-scrollbar {
    width: 4px;
}

.locations-list-long::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.locations-list-long::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
}

/* =============================================================================
   ALTERNATYWY I SUGESTIE
   ============================================================================= */

.suggestions-section {
    margin-top: var(--md-spacing-md);
    padding: var(--md-spacing-md);
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--md-radius-sm);
    border-left: 3px solid rgba(255,255,255,0.5);
}

.suggestions-title {
    font-weight: 500;
    margin-bottom: var(--md-spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--md-spacing-xs);
    font-size: 0.75rem;
}

.suggestion-item {
    padding: var(--md-spacing-xs) 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    line-height: 1.3;
    font-size: 0.75rem;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-available {
    color: var(--md-success);
    font-weight: 500;
}

.suggestion-similar {
    color: var(--md-warning);
    font-style: italic;
}

/* =============================================================================
   KOMUNIKATY BŁĘDÓW
   ============================================================================= */

.error {
    background: var(--md-error-light);
    color: var(--md-error);
    border: 1px solid rgba(211, 47, 47, 0.2);
    padding: var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    margin: var(--md-spacing-md) 0;
    display: none;
    font-size: 0.875rem;
    box-shadow: var(--md-shadow-1dp);
}

/* =============================================================================
   DIAGNOSTYKA I TESTOWANIE
   ============================================================================= */

.connection-test {
    background: white;
    border: 1px solid var(--md-outline-variant);
    padding: var(--md-spacing-md);
    border-radius: var(--md-radius-sm);
    margin-bottom: var(--md-spacing-xl);
    box-shadow: var(--md-shadow-1dp);
}

.connection-test h3 {
    margin-bottom: var(--md-spacing-md);
    color: var(--md-on-surface);
    font-size: 1rem;
    font-weight: 500;
}

.test-result {
    padding: var(--md-spacing-sm);
    margin: var(--md-spacing-xs) 0;
    border-radius: var(--md-radius-sm);
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    border-left: 3px solid;
}

.test-success {
    background: var(--md-success-light);
    color: var(--md-success);
    border-color: var(--md-success);
}

.test-error {
    background: var(--md-error-light);
    color: var(--md-error);
    border-color: var(--md-error);
}

.test-warning {
    background: var(--md-warning-light);
    color: var(--md-warning);
    border-color: var(--md-warning);
}

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

@media (max-width: 1024px) {
    .header-search {
        flex: 0 0 350px;
        max-width: 350px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: var(--md-spacing-md);
    }

    .header-search {
        flex: 1 1 auto;
        max-width: 100%;
    }

    .legend-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--md-spacing-sm);
    }

    .content {
        padding: var(--md-spacing-md);
    }

    .search-button {
        min-height: 52px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 0.875rem;
    }

    .header {
        padding: var(--md-spacing-md);
    }

    .header-text h1 {
        font-size: 1.25rem;
    }

    .header-text p {
        font-size: 0.75rem;
    }

    .gmina-search-input,
    .ulice-input textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .legend-bar {
        padding: var(--md-spacing-sm);
    }

    .legend-item {
        font-size: 0.75rem;
    }

    .content {
        padding: var(--md-spacing-sm);
    }

    .ulice-input {
        padding: var(--md-spacing-md);
    }

    .result-item {
        padding: var(--md-spacing-sm);
        font-size: 0.8125rem;
    }

    .suggestions-section {
        padding: var(--md-spacing-sm);
    }
}

/* =============================================================================
   MATERIAL DESIGN ELEVATION HOVER EFFECTS
   ============================================================================= */

.result-item:hover {
    box-shadow: var(--md-shadow-2dp);
    transform: translateY(-1px);
}

.gmina-dropdown {
    animation: materialFadeIn 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes materialFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
