/**
 * Tourenplaner – Stylesheet
 *
 * Responsive Design für Desktop und Smartphone.
 * Farben und Layout orientieren sich an einer professionellen
 * Business-Anwendung.
 */

/* === CSS-Variablen === */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
}

/* === Reset & Basis === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* === Header === */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 60px;
    gap: 2rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
}

.logo:hover {
    text-decoration: none;
}

/* === Navigation === */
.nav {
    flex: 1;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 0.25rem;
}

.nav-links a {
    display: block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
    background: var(--gray-100);
    color: var(--gray-800);
    text-decoration: none;
}

.nav-links a.active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    gap: 4px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--gray-600);
    border-radius: 1px;
}

/* === User-Menü === */
.user-menu {
    position: relative;
}

.user-name {
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--gray-700);
}

.user-name:hover {
    background: var(--gray-100);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 200;
    overflow: hidden;
}

.user-menu:hover .user-dropdown {
    display: block;
}

.user-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    border-bottom: 1px solid var(--gray-100);
}

.user-dropdown a:last-child {
    border-bottom: none;
}

.user-dropdown a:hover {
    background: var(--gray-50);
    text-decoration: none;
}

/* === Main Content === */
.main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--gray-400);
    font-size: 0.85rem;
    border-top: 1px solid var(--gray-200);
}

/* === Seitenheader === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    color: var(--gray-900);
}

.page-header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

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

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm,
.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-warning:hover {
    background: #b45309;
}

.btn-full {
    width: 100%;
}

/* === Formulare === */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-row .flex-1 { flex: 1; }
.form-row .flex-2 { flex: 2; }

.form-group-small {
    max-width: 120px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-item {
    display: block;
}

.checkbox-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: normal;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* === Tabellen === */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--gray-50);
}

.data-table .actions {
    white-space: nowrap;
    display: flex;
    gap: 0.5rem;
}

.data-table code {
    background: var(--gray-100);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.perm-summary {
    max-width: 400px;
    font-size: 0.85rem;
    color: var(--gray-600);
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-small {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

/* === Karten === */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 1.5rem;
}

.card-narrow {
    max-width: 480px;
}

/* === Dashboard === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.dashboard-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.dashboard-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.dashboard-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.dashboard-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.dashboard-card p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* === Modal === */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show,
.modal.open {
    display: flex;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
}

.modal-large .modal-content {
    max-width: 720px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body h3 {
    font-size: 1rem;
    margin: 1rem 0 0.75rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 0.5rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.search-input {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    min-width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ansprechpartner-item {
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.ansprechpartner-item .form-row {
    align-items: flex-end;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* === Berechtigungstabelle === */
.permissions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.permissions-table th,
.permissions-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    text-align: center;
}

.permissions-table th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.8rem;
}

.permissions-table td:first-child {
    text-align: left;
    font-weight: 500;
}

.permissions-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* === Alerts === */
.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #86efac;
}

.alert-info {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid #93c5fd;
}

/* === Toast-Benachrichtigungen === */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success {
    background: var(--success);
    color: var(--white);
}

.toast-error {
    background: var(--danger);
    color: var(--white);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* === Login-Seite === */
.login-page {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--gray-100) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
}

.login-title {
    text-align: center;
    color: var(--primary);
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

/* === 404-Seite === */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 5rem;
    color: var(--gray-300);
    margin-bottom: 0.5rem;
}

.error-page p {
    color: var(--gray-500);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* === Loading === */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
}

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

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--white);
        border-bottom: 1px solid var(--gray-200);
        box-shadow: var(--shadow-md);
        flex-direction: column;
        padding: 0.5rem;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 0.75rem 1rem;
    }

    .main {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .modal-content {
        width: 95%;
        margin: 0.5rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .data-table .actions {
        flex-direction: column;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .user-name {
        display: none;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 1.5rem;
    }

    .login-title {
        font-size: 1.5rem;
    }
}
