/* Basic CSS Reset and Variables */
:root {
    --primary-green-tanne: #005538;
    --primary-green-klee: #008939;
    --primary-green-grashalm: #60ad5e;
    --accent-green: #8abd24;
    --text-dark: #1a1a1a;
    --text-medium: #4a4a4a;
    --text-light: #6a6a6a;
    --sand: #f5f1e9;
    --background-white: #ffffff;
    --background-light: #f8f9fa;
    --background-green-light: #f1f8f0;
    --green-gradient: radial-gradient(circle, #76bd82, #3a814a);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s ease;
    --yellow-sonne: #FFF17A;
    --blue-himmel: #0ba1dd;
    --magenta: #e6007e;
}

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

html {
    height: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
    width: 100%;
    max-width: 100vw;
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
}

html::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100vw;
    height: 100%;
    min-height: 100vh;
    background: var(--green-gradient);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    z-index: -1;
    pointer-events: none;
    background-color: transparent;
    box-sizing: border-box;
}

body {
    font-family: 'PT Sans', Arial, sans-serif;
    color: var(--sand);
    line-height: 1.6;
    min-height: 100vh;
    background: transparent;
    position: relative;
    z-index: 0;
    overflow-y: visible;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
}

/* Font Face Declarations */
@font-face {
    font-family: 'GrueneType';
    src: url('fonts/GrueneType/GrueneType.woff2') format('woff2'),
         url('fonts/GrueneType/GrueneType.woff') format('woff'),
         url('fonts/GrueneType/GrueneType.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

/* Headings - Apply GrueneType font */
h1, h2, h3, h4, h5, h6 {
    font-family: 'GrueneType', Arial, sans-serif;
    color: var(--sand);
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
    font-weight: normal;
}

h2 {
    font-size: 1.5rem;
    font-weight: normal;
}

/* Sticky Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--primary-green-tanne);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    transition: var(--transition);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.header-logo {
    height: 40px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

.header-user-name {
    margin: 0 1rem;
    color: var(--sand);
    font-family: 'GrueneType', Arial, sans-serif;
    font-size: 1.2rem;
    white-space: nowrap;
}

.hamburger-menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    z-index: 1001;
}

.hamburger-menu-btn span {
    width: 100%;
    height: 3px;
    background: var(--sand);
    border-radius: 2px;
    transition: var(--transition);
    transform-origin: center;
}

.hamburger-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.hamburger-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--primary-green-tanne);
    box-shadow: var(--shadow-lg);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Desktop: narrower hamburger menu, aligned to right */
@media (min-width: 768px) {
    .hamburger-menu {
        left: auto;
        right: 1rem;
        width: 300px;
        max-width: calc(100vw - 2rem);
        border-radius: 0 0 8px 8px;
    }
    
    /* When container is centered, align menu to container's right edge */
    @media (min-width: 1200px) {
        .hamburger-menu {
            right: calc((100vw - 1200px) / 2 + 1rem);
        }
    }
}

.hamburger-menu.active {
    max-height: 400px;
    overflow-y: auto;
}

.menu-content {
    padding: 1rem 0;
}

.menu-item {
    width: 100%;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(245, 241, 233, 0.2);
    color: var(--sand);
    text-align: left;
    font-size: 1rem;
    font-family: 'PT Sans', Arial, sans-serif;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

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

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
    background: rgba(255, 255, 255, 0.15);
    font-weight: 600;
}

.menu-divider {
    height: 1px;
    background: rgba(245, 241, 233, 0.3);
    margin: 0.5rem 1.5rem;
}

.menu-item-logout {
    color: rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(245, 241, 233, 0.2);
    margin-top: 0.5rem;
}

.menu-item-logout:hover {
    background: rgba(230, 0, 126, 0.2);
    color: var(--sand);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    color: var(--text-dark);
}

/* Card Headings */
.card h1,
.card h2,
.card h3 {
    color: var(--primary-green-tanne);
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
}

.welcome-message h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.welcome-message p {
    font-size: 1.1rem;
    color: var(--sand);
}

/* Onboarding Screen */
.onboarding-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.onboarding-form {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    color: var(--text-dark);
}

.onboarding-form h2 {
    color: var(--primary-green-tanne);
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 1.1rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: 'PT Sans', Arial, sans-serif;
    transition: var(--transition);
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: checkbox;
    width: auto;
    min-height: auto;
    padding: 0;
    accent-color: var(--primary-green-klee);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-green-klee);
    box-shadow: 0 0 0 3px rgba(0, 137, 57, 0.1);
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* Street Search, House Number, Visit styles moved to modules/haustuerwahl/module.css */

/* Buttons */
.btn {
    display: inline-block;
    padding: 1rem 1.5rem;
    background: var(--primary-green-klee);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: 'PT Sans', Arial, sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
    width: 100%;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Desktop: smaller buttons, not full width */
@media (min-width: 768px) {
    .btn {
        width: auto;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        min-height: 44px;
    }
}

.btn:hover {
    background: var(--primary-green-tanne);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--text-medium);
    min-height: 44px;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* Visit Status Badge and Visit List styles moved to modules/haustuerwahl/module.css */

/* Loading Spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: calc(100% - 2.5rem);
    width: 100%;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid;
    min-width: 280px;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(120%);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast.toast-hiding {
    opacity: 0;
    transform: translateX(120%);
}

.toast-success {
    border-left-color: var(--primary-green-tanne, #00a651);
}

.toast-error {
    border-left-color: #dc3545;
}

.toast-warning {
    border-left-color: #ffa500;
}

.toast-info {
    border-left-color: var(--blue-himmel, #0066cc);
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
    font-weight: bold;
}

.toast-success .toast-icon {
    color: var(--primary-green-tanne, #00a651);
}

.toast-error .toast-icon {
    color: #dc3545;
}

.toast-warning .toast-icon {
    color: #ffa500;
}

.toast-info .toast-icon {
    color: var(--blue-himmel, #0066cc);
}

.toast-content {
    flex: 1;
    color: var(--text-dark, #333);
    font-size: 0.9375rem;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-medium, #666);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-dark, #333);
}

.toast-close:active {
    background: rgba(0, 0, 0, 0.15);
}

/* Confirmation Dialog System */
.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
    backdrop-filter: blur(2px);
}

.confirm-dialog-overlay.hidden {
    display: none;
}

.confirm-dialog {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.confirm-dialog-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark, #333);
    margin-bottom: 1rem;
}

.confirm-dialog-message {
    color: var(--text-medium, #666);
    margin-bottom: 1.5rem;
    line-height: 1.5;
    font-size: 1rem;
}

.confirm-dialog-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.confirm-dialog-actions button {
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    min-width: 100px;
}

.confirm-dialog-cancel {
    background: var(--background-light, #f8f9fa);
    color: var(--text-dark, #333);
}

.confirm-dialog-cancel:hover {
    background: #e5e5e5;
}

.confirm-dialog-confirm {
    background: var(--primary-green-tanne, #005538);
    color: white;
}

.confirm-dialog-confirm:hover {
    background: var(--primary-green-klee, #008939);
}

.confirm-dialog-confirm.btn-remove-poster {
    background: #dc3545;
}

.confirm-dialog-confirm.btn-remove-poster:hover {
    background: #c82333;
}

/* Pull-to-Refresh Indicator */
.pull-to-refresh-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-60px);
    transition: opacity 0.2s, transform 0.2s;
}

.pull-indicator-content {
    background: var(--primary-green-klee, #008939);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 12px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pull-to-refresh-indicator.pull-ready .pull-indicator-content {
    background: var(--primary-green-tanne, #005538);
}

.pull-to-refresh-indicator.pull-refreshing .pull-indicator-content {
    background: var(--blue-himmel, #0066cc);
}

/* Mobile Optimizations for Toast */
@media (max-width: 480px) {
    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: calc(100% - 2rem);
        width: auto;
    }
    
    .toast {
        min-width: 0;
        width: 100%;
    }
    
    .confirm-dialog {
        padding: 1.5rem;
        width: 95%;
    }
    
    .confirm-dialog-title {
        font-size: 1.125rem;
    }
    
    .confirm-dialog-message {
        font-size: 0.9375rem;
    }
    
    .confirm-dialog-actions {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }
    
    .confirm-dialog-actions button {
        width: 100%;
    }
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
        padding-top: 5rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .card-section-headline {
        font-size: 1.5rem;
    }
    
    .header-logo {
        height: 32px;
        max-width: 150px;
    }
    
    .header-content {
        padding: 0.5rem 0.75rem;
    }
}

/* Admin Panel */
.admin-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    color: var(--text-dark);
}

.admin-section {
    margin-bottom: 2rem;
}

.admin-section h3 {
    color: var(--primary-green-tanne);
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-green-klee);
    padding-bottom: 0.5rem;
}

/* Module Container */
#module-container {
    padding-top: 0;
}

#module-container:not(.hidden) {
    padding-top: 0;
}

/* Card Menu */
.card-menu {
    margin-bottom: 2rem;
}

/* Card Section */
.card-section {
    margin-bottom: 2rem;
}

.card-section-headline {
    color: var(--sand);
    font-size: 2rem;
    font-weight: normal;
    margin-bottom: 1.5rem;
    text-align: center;
}

.card-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

/* Two columns from tablet up; cards in grid use gap only */
@media (min-width: 768px) {
    .card-section-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.card-section-grid .card {
    margin-bottom: 0;
    min-width: 0; /* allow grid item to shrink so content wraps */
}

.card-menu-item h2 {
    margin-bottom: 0.5rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

.card-menu-item p {
    margin: 0;
    color: var(--text-medium);
    font-size: 0.95rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--background-white);
    border-bottom: 3px solid var(--primary-green-klee);
    box-shadow: var(--shadow-md);
    z-index: 999;
    transition: transform 0.3s ease, opacity 0.3s ease, top 0.3s ease;
    transform: translateY(0);
    opacity: 1;
}

.pwa-install-banner.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.pwa-banner-content {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    gap: 0.75rem;
}

.pwa-banner-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.pwa-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--text-dark);
    font-size: 0.9375rem;
    line-height: 1.4;
}

.pwa-banner-text strong {
    color: var(--primary-green-tanne);
    font-weight: 600;
}

.pwa-install-instructions {
    color: var(--text-medium);
    font-size: 0.875rem;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .pwa-banner-content {
        padding: 0.75rem 0.875rem;
        gap: 0.5rem;
    }
    
    .pwa-banner-icon {
        font-size: 1.25rem;
    }
    
    .pwa-banner-text {
        font-size: 0.875rem;
    }
    
    .pwa-install-instructions {
        font-size: 0.8125rem;
    }
}
