/* ====================================
   Sanavo Praxissoftware - Stylesheet
   ==================================== */

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;

    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --bg-color: #f8fafc;
    --bg-white: #ffffff;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --border-radius: 6px;
    --box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== Navigation ========== */
.navbar {
    background: linear-gradient(180deg, #e8f4fc 0%, #d6ecf8 100%);
    border-bottom: 1px solid #c5dce8;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    padding: 0 2rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
}

.navbar-brand a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 700;
}

.navbar-brand img {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.navbar-brand .brand-text {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.navbar-brand .brand-name {
    font-weight: 700;
    color: var(--primary-color);
}

.navbar-brand .brand-suffix {
    font-weight: 400;
    color: #64748b;
    font-size: 0.9em;
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 0;
    align-items: center;
    margin: 0;
    padding: 0;
}

.navbar-menu > li {
    position: relative;
}

.navbar-menu > li > a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #475569;
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.navbar-menu > li > a:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.navbar-menu > li > a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
}

.navbar-menu > li > a svg {
    flex-shrink: 0;
}

.navbar-user {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem 0;
    margin-left: 1rem;
    border-left: 1px solid #c5dce8;
    padding-left: 1.5rem;
}

.navbar-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    border: 1px solid #c5dce8;
}

.navbar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.navbar-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #1e293b;
}

/* ========== Alerts ========== */
.alert {
    padding: 0.875rem 1.25rem;
    margin: 1rem auto;
    max-width: 1200px;
    border-radius: 10px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.alert-success {
    background: #d1fae5;
    border-color: var(--success-color);
    color: #065f46;
}

.alert-error {
    background: #fee2e2;
    border-color: var(--danger-color);
    color: #991b1b;
}

.alert-info {
    background: #dbeafe;
    border-color: var(--info-color);
    color: #1e40af;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: var(--text-color);
}

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

.form-control::placeholder {
    color: #94a3b8;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success-color);
    color: white;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.25);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.25);
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: translateY(-1px);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-logout {
    background: transparent;
    color: #64748b;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fee2e2;
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

/* ========== Login Page ========== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--bg-white);
    border-radius: 10px;
    padding: 2.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========== Tables ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead {
    background: #f8fafc;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #64748b;
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-white);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.5rem;
    color: var(--text-color);
}

/* ========== Main Content ========== */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 1.5rem 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--text-color);
}

.page-header__actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ========== Footer ========== */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========== Typography Settings ========== */
.typography-page .page-header h1 {
    margin: 0 0 0.25rem 0;
}

.typography-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.typography-section {
    padding: 0;
}

.typography-section.is-disabled {
    opacity: 0.6;
}

.typography-section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 1.5rem 1rem;
}

.typography-section__header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
    color: var(--text-color);
}

.typography-preview {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    min-height: 48px;
    display: flex;
    align-items: center;
}

.typography-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 0 1.5rem 1.5rem;
}

.typography-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.typography-field input,
.typography-field select {
    width: 100%;
}

.typography-field input[type="color"] {
    height: 40px;
}

.typography-actions {
    display: flex;
    justify-content: flex-end;
}

.toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle input {
    display: none;
}

.toggle__track {
    width: 48px;
    height: 26px;
    background: #e2e8f0;
    border-radius: 999px;
    position: relative;
    transition: background 0.2s;
}

.toggle__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.toggle input:checked + .toggle__track {
    background: var(--primary-color);
}

.toggle input:checked + .toggle__track::after {
    transform: translateX(22px);
}

/* ========== API Keys ========== */
.api-keys-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.api-keys-section {
    padding: 0;
}

.api-keys-section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 1.5rem 1rem;
}

.api-keys-fields {
    padding: 0 1.5rem 1.5rem;
}

.api-keys-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.api-keys-actions {
    display: flex;
    justify-content: flex-end;
}

/* ========== Fonts Library ========== */
.fonts-toolbar {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.fonts-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fonts-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.fonts-card__header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-color);
}

.fonts-card__meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.fonts-card__preview {
    font-size: 1.1rem;
    color: var(--text-color);
    line-height: 1.4;
    min-height: 72px;
}

.fonts-card__actions {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 720px) {
    .fonts-toolbar {
        grid-template-columns: 1fr;
    }
}

/* ========== Modern Interaction States ========== */
a {
    transition: color 0.15s ease;
}

::selection {
    background: rgba(37, 99, 235, 0.15);
    color: inherit;
}

html {
    scroll-behavior: smooth;
}

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ========== Utilities ========== */
.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.625rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 999px;
    line-height: 1.4;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

/* ========== Mobile Responsive ========== */
@media (max-width: 768px) {

    /* --- Navigation --- */
    .navbar .container {
        padding: 0 0.5rem;
        flex-wrap: nowrap;
    }

    .navbar-brand {
        padding: 0.5rem 0;
    }

    .navbar-brand a {
        font-size: 1.1rem;
        gap: 0.35rem;
    }

    .navbar-brand img {
        height: 28px;
    }

    .navbar-menu {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0;
    }

    .navbar-menu::-webkit-scrollbar {
        display: none;
    }

    .navbar-menu > li > a {
        padding: 0.7rem 0.6rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .navbar-menu > li > a span {
        display: none; /* Nur Icons auf Mobile */
    }

    .navbar-menu > li > a svg {
        width: 20px;
        height: 20px;
    }

    .navbar-user-name {
        display: none; /* Name ausblenden auf Mobile */
    }

    .navbar-user {
        padding-left: 0.5rem;
        margin-left: 0.25rem;
    }

    .navbar-user-info {
        padding: 0.35rem 0.5rem;
    }

    /* --- Main Content --- */
    .main-content {
        padding: 0.75rem 0;
    }

    .container {
        padding: 0 0.75rem;
    }

    /* --- Page Header --- */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    .page-header .btn,
    .page-header a.btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* --- Buttons - kleiner auf Mobile --- */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .btn-sm {
        padding: 0.35rem 0.7rem;
        font-size: 0.8rem;
    }

    /* --- Tables scrollbar --- */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Cards --- */
    .card {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .card-header {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card-header h2 {
        font-size: 1rem;
    }

    /* --- Grids auf Mobile stapeln --- */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* --- Tables auf Mobile --- */
    table {
        font-size: 0.85rem;
    }

    table th,
    table td {
        padding: 0.5rem 0.6rem;
    }

    /* --- Filter Chips auf Mobile --- */
    .filter-chip {
        padding: 0.3rem 0.65rem;
        font-size: 0.75rem;
    }

    /* --- Dashboard-Karten --- */
    .dashboard-cards,
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    .dashboard-card {
        padding: 1rem;
    }

    /* --- Footer --- */
    .footer {
        padding: 0.75rem 0;
        margin-top: 1rem;
        font-size: 0.75rem;
    }

    /* --- Termin-Tagesansicht: Sidebar unter Kalender --- */
    .day-view-grid {
        display: flex !important;
        flex-direction: column-reverse !important;
        gap: 1rem !important;
    }

    /* --- Kalender-Header auf Mobile --- */
    .calendar-header {
        flex-direction: column !important;
        gap: 0.5rem !important;
        padding: 0.75rem !important;
    }

    .calendar-header > div:last-child {
        flex-wrap: wrap;
        gap: 0.35rem !important;
        width: 100%;
    }

    .calendar-header h1 {
        font-size: 1.1rem !important;
    }

    /* --- Termin-Karten auf Mobile --- */
    .appointment {
        padding: 0.5rem !important;
        font-size: 0.85rem;
    }

    /* --- Billing/Rechnungen Cards --- */
    .billing-stats,
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    /* --- Patient-Tab-Buttons --- */
    .patient-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0;
    }

    .patient-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* --- Flex-Gap auf Mobile verkleinern --- */
    [style*="display: flex"][style*="gap: 1rem"] {
        gap: 0.5rem !important;
    }

    /* --- Inline Grids auf Mobile -> 1 Spalte --- */
    [style*="grid-template-columns: 1fr 1fr 1fr"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns: 2fr 1fr"],
    [style*="grid-template-columns: 1fr 2fr"] {
        grid-template-columns: 1fr !important;
    }

    [style*="grid-template-columns: 1fr 1fr;"],
    [style*="grid-template-columns: 1fr 1fr auto"] {
        grid-template-columns: 1fr !important;
    }

    /* --- Inline-Flex mit großem Gap verkleinern --- */
    [style*="gap: 2rem"],
    [style*="gap: 1.5rem"] {
        gap: 0.75rem !important;
    }

    /* --- Zu große Paddings reduzieren --- */
    [style*="padding: 3rem"],
    [style*="padding: 2.5rem"] {
        padding: 1.25rem !important;
    }

    [style*="padding: 2rem"] {
        padding: 1rem !important;
    }

    /* --- Modals --- */
    .modal-content {
        width: 95%;
        max-height: 85vh;
        overflow-y: auto;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .navbar .container {
        padding: 0 0.35rem;
    }

    .navbar-brand a {
        font-size: 1rem;
    }

    .navbar-brand img {
        height: 24px;
    }

    .navbar-menu > li > a {
        padding: 0.7rem 0.45rem;
        font-size: 0.75rem;
    }

    .navbar-menu > li > a svg {
        width: 18px;
        height: 18px;
    }

    .btn-logout {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    .container {
        padding: 0 0.5rem;
    }

    h2 {
        font-size: 1.1rem;
    }
}

/* ========== Global Mobile Enhancements ========== */
/* Tabellen responsive machen */
.data-table {
    min-width: 100%;
}

@media (max-width: 768px) {
    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.4rem 0.5rem;
    }

    /* Sub-Navigation (Billing etc.) scrollbar */
    .sub-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap !important;
    }

    .sub-nav::-webkit-scrollbar {
        display: none;
    }

    .sub-nav a,
    .sub-nav-link {
        white-space: nowrap;
        font-size: 0.8rem !important;
        padding: 0.4rem 0.7rem !important;
    }

    /* KPI Cards (Billing) */
    .kpi-card {
        padding: 0.75rem !important;
    }

    .kpi-value {
        font-size: 1.2rem !important;
    }

    .kpi-label {
        font-size: 0.75rem !important;
    }

    /* Allgemeine Flex-Layouts verbessern */
    [style*="display: flex"][style*="justify-content: space-between"] {
        flex-wrap: wrap;
    }
}
