/* ========================================
   Pixel Ads GmbH - Erinnerungsservice
   Markenfarben & Responsive Design
   ======================================== */

:root {
    --color-text: #333333;
    --color-primary: #f6ab17;
    --color-secondary: #d21f27;
    --color-primary-dark: #e88c14;
    --color-secondary-dark: #ae1b26;
    --color-bg: #faf8f3;
    --color-white: #ffffff;
    --color-border: #e5e2db;
    --color-muted: #888888;
    --color-success: #28a745;
    --color-info: #17a2b8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- Layout ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--color-text);
    color: var(--color-white);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

.sidebar-header .subtitle {
    font-size: 12px;
    color: var(--color-muted);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--color-white);
}

.sidebar-nav a.active {
    background: rgba(246,171,23,0.1);
    color: var(--color-primary);
    border-left-color: var(--color-primary);
}

.sidebar-nav a .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 13px;
}

.sidebar-footer a:hover {
    color: var(--color-secondary);
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

/* ---- Mobile Nav Toggle ---- */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--color-text);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius);
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

/* ---- Page Header ---- */
.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.page-header .description {
    color: var(--color-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ---- Cards ---- */
.card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 20px;
}

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.primary { background: rgba(246,171,23,0.12); color: var(--color-primary); }
.stat-icon.danger { background: rgba(210,31,39,0.1); color: var(--color-secondary); }
.stat-icon.success { background: rgba(40,167,69,0.1); color: var(--color-success); }
.stat-icon.info { background: rgba(23,162,184,0.1); color: var(--color-info); }
.stat-icon.muted { background: rgba(136,136,136,0.1); color: var(--color-muted); }

.stat-content .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.stat-content .stat-label {
    font-size: 13px;
    color: var(--color-muted);
    margin-top: 4px;
}

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

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

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

table tbody tr:hover {
    background: rgba(246,171,23,0.04);
}

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

/* ---- Badges / Tags ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-open { background: #e8f5e9; color: #2e7d32; }
.badge-overdue { background: #fce4ec; color: #c62828; }
.badge-paid { background: #e3f2fd; color: #1565c0; }
.badge-partial { background: #fff3e0; color: #e65100; }
.badge-paused { background: #f3e5f5; color: #7b1fa2; }
.badge-lastschrift { background: #e0e0e0; color: #616161; }

/* Stage badges */
.stage-none { background: #f5f5f5; color: #9e9e9e; }
.stage-due { background: #e8f5e9; color: #2e7d32; }
.stage-reminder { background: #fff3e0; color: var(--color-primary-dark); }
.stage-mahnung { background: #fce4ec; color: var(--color-secondary); }
.stage-mahnung-final { background: var(--color-secondary); color: var(--color-white); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
}

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-border);
    color: var(--color-text);
}
.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    min-height: 36px;
}

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

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-group .hint {
    font-size: 12px;
    color: var(--color-muted);
    margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-white);
    transition: border-color 0.2s;
    min-height: 44px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(246,171,23,0.15);
}

textarea {
    min-height: 180px;
    resize: vertical;
}

/* ---- Toggle Switch ---- */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
}

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    display: inline-block;
}

.toggle input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    min-height: 0;
    position: absolute;
    pointer-events: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--color-success);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* ---- Alerts ---- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-warning {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc02;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.alert-danger {
    background: #fce4ec;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.alert-info {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

/* ---- Status Indicator ---- */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.active { background: var(--color-success); }
.status-dot.inactive { background: var(--color-muted); }
.status-dot.error { background: var(--color-secondary); }

/* ---- Sync Banner ---- */
.sync-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--color-white);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--color-muted);
    flex-wrap: wrap;
    gap: 10px;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 20px 0;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 14px;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.pagination a:hover {
    border-color: var(--color-primary);
    background: rgba(246,171,23,0.08);
}

.pagination .active {
    background: var(--color-primary);
    color: var(--color-text);
    border-color: var(--color-primary);
    font-weight: 600;
}

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: end;
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

.filter-bar select,
.filter-bar input {
    min-height: 40px;
}

/* ---- Detail Grid ---- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.detail-item label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.detail-item .value {
    font-size: 16px;
    font-weight: 500;
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 20px;
}

.login-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    font-size: 22px;
    margin-bottom: 8px;
    color: var(--color-primary);
}

.login-card .subtitle {
    text-align: center;
    font-size: 14px;
    color: var(--color-muted);
    margin-bottom: 28px;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 15px;
}

/* ---- Template Preview ---- */
.template-preview {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

/* ---- Utilities ---- */
.text-muted { color: var(--color-muted); }
.text-danger { color: var(--color-secondary); }
.text-success { color: var(--color-success); }
.text-primary { color: var(--color-primary); }
.font-mono { font-family: 'SF Mono', Monaco, monospace; font-size: 13px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 16px; }
.gap-1 { gap: 8px; }

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 1024px) {
    .main-content {
        padding: 24px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .mobile-nav-toggle {
        display: flex;
    }
    .main-content {
        margin-left: 0;
        padding: 70px 16px 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .page-header h2 {
        font-size: 20px;
    }
    .filter-bar {
        flex-direction: column;
    }
    .filter-bar .form-group {
        min-width: 100%;
    }

    /* Responsive table -> card layout */
    table, thead, tbody, th, td, tr {
        display: block;
    }
    thead {
        display: none;
    }
    tbody tr {
        background: var(--color-white);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        padding: 12px 16px;
        margin-bottom: 8px;
    }
    tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid var(--color-border);
    }
    tbody td:last-child {
        border-bottom: none;
    }
    tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        color: var(--color-muted);
        margin-right: 10px;
        flex-shrink: 0;
    }
    tbody tr:hover {
        background: var(--color-white);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 60px 12px 12px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-content .stat-value {
        font-size: 24px;
    }
    .card-body {
        padding: 16px;
    }
    .login-card {
        padding: 28px 20px;
    }
    .btn {
        width: 100%;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
}
