/**
 * Kontaktmanagement - Admin Styles
 */

/* ========================================
   VARIABLES
======================================== */
:root {
    --primary: #8a9a8e;
    --primary-dark: #6b7b6f;
    --primary-light: #a8b5ab;
    --secondary: #f5f1eb;
    --accent: #c9a86c;
    
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    
    --text: #333;
    --text-muted: #666;
    --text-light: #999;
    
    --bg: #f8f9fa;
    --bg-white: #fff;
    --border: #dee2e6;
    
    --sidebar-width: 260px;
    --header-height: 60px;
    
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-sm: 4px;
    
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

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

a:hover {
    color: var(--primary);
}

/* ========================================
   LOGIN PAGE
======================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--bg) 100%);
}

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

.login-box {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--primary-dark);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-muted);
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.login-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.back-link {
    color: var(--text-muted);
    font-size: 13px;
}

/* ========================================
   ADMIN WRAPPER
======================================== */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ========================================
   SIDEBAR
======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

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

.sidebar-logo {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.sidebar-subtitle {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    transition: all var(--transition);
    position: relative;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
}

.nav-icon {
    font-size: 18px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    margin-bottom: 10px;
}

.user-name {
    display: block;
    font-weight: 500;
}

.user-time {
    font-size: 11px;
    opacity: 0.7;
}

.logout-btn {
    display: block;
    text-align: center;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: background var(--transition);
}

.logout-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ========================================
   MAIN CONTENT
======================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
}

/* ========================================
   BUTTONS
======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

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

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

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

.btn-outline:hover {
    background: var(--bg);
    color: var(--text);
}

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

.btn-danger:hover {
    background: #c82333;
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

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

/* ========================================
   CARDS
======================================== */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* ========================================
   ALERTS
======================================== */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ========================================
   BADGES
======================================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 20px;
    text-transform: uppercase;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e9ecef; color: #495057; }
.badge-dark { background: #343a40; color: #fff; }
.badge-new { background: var(--primary); color: #fff; margin-left: 8px; }

/* ========================================
   TABLES
======================================== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
}

.table-hover tbody tr:hover {
    background: var(--bg);
}

.row-unread {
    background: #f0f7ff;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

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

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ========================================
   FILTER BAR
======================================== */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-white);
    padding: 15px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.filter-form {
    display: flex;
    gap: 15px;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.filter-input,
.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.filter-info {
    color: var(--text-muted);
    font-size: 13px;
}

/* ========================================
   DASHBOARD
======================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-primary::before { background: var(--primary); }
.stat-warning::before { background: var(--warning); }
.stat-danger::before { background: var(--danger); }
.stat-info::before { background: var(--info); }

.stat-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
}

.stat-link {
    display: block;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--primary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.info-card {
    background: var(--secondary);
    padding: 20px;
    border-radius: var(--radius);
}

.info-card h4 {
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.info-card p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

/* ========================================
   CONTACT DETAIL
======================================== */
.detail-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-row-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-fullwidth {
    width: 100%;
}

/* Kontaktinfo */
.contact-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.info-icon {
    font-size: 18px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.info-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-weight: 500;
    font-size: 15px;
}

.info-link {
    color: var(--primary);
    text-decoration: none;
}

.info-link:hover {
    text-decoration: underline;
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding-left: 20px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    position: relative;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 14px;
    width: 12px;
    height: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50%;
    z-index: 1;
}

.timeline-success .timeline-dot {
    border-color: var(--success);
    background: var(--success);
}

.timeline-info .timeline-dot {
    border-color: var(--primary);
    background: var(--primary);
}

.timeline-warning .timeline-dot {
    border-color: var(--warning);
    background: var(--warning);
}

.timeline-current .timeline-dot {
    border-color: var(--primary);
    background: var(--primary);
    width: 14px;
    height: 14px;
    left: -21px;
    top: 13px;
}

.timeline-current .timeline-content {
    font-weight: 500;
}

.timeline-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-label {
    font-size: 13px;
    color: var(--text-muted);
}

.timeline-value {
    font-size: 13px;
    font-weight: 500;
}

/* Nachricht */
.message-box {
    background: var(--bg);
    padding: 24px;
    border-radius: var(--radius-sm);
    line-height: 1.8;
    font-size: 15px;
    border-left: 4px solid var(--primary);
}

/* Aktionen */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.actions-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-item label {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.action-inline {
    display: flex;
    gap: 8px;
}

.action-inline select {
    min-width: 140px;
}

.actions-danger {
    margin-left: auto;
}

/* Notizen */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.note-item {
    background: var(--bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.note-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.note-author {
    font-weight: 600;
    color: var(--text);
}

.note-date {
    color: var(--text-muted);
}

.note-content {
    font-size: 14px;
    line-height: 1.6;
}

.note-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-form textarea {
    resize: vertical;
    min-height: 80px;
}

.note-form button {
    align-self: flex-end;
}

/* ========================================
   LOGS
======================================== */
.stats-mini {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.stat-mini {
    background: var(--bg-white);
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-mini-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
}

.stat-mini-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-mini-warning .stat-mini-value { color: var(--warning); }
.stat-mini-error .stat-mini-value { color: var(--danger); }
.stat-mini-critical .stat-mini-value { color: var(--danger); }

.log-list {
    max-height: 600px;
    overflow-y: auto;
}

.log-item {
    padding: 12px 15px;
    border-left: 3px solid var(--border);
    margin-bottom: 10px;
    background: var(--bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.log-level-info { border-left-color: var(--info); }
.log-level-warning { border-left-color: var(--warning); }
.log-level-error { border-left-color: var(--danger); }
.log-level-critical { border-left-color: var(--danger); background: #fff5f5; }
.log-level-debug { border-left-color: var(--text-muted); }

.log-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.log-level {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.log-time {
    font-size: 11px;
    color: var(--text-muted);
}

.log-message {
    font-size: 13px;
}

.log-context {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: var(--radius-sm);
    font-size: 12px;
    overflow-x: auto;
}

.log-context code {
    white-space: pre-wrap;
    word-break: break-all;
}

/* ========================================
   SETTINGS
======================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.settings-form {
    max-width: 400px;
}

.maintenance-action h4 {
    margin-bottom: 8px;
}

.maintenance-action p {
    margin-bottom: 15px;
}

.info-list .info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.info-label {
    color: var(--text-muted);
}

.hash-generator {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.hash-output {
    background: var(--bg);
    padding: 15px;
    border-radius: var(--radius-sm);
}

.hash-output code {
    display: block;
    word-break: break-all;
    margin-bottom: 10px;
}

.hash-output small {
    color: var(--text-muted);
}

/* ========================================
   PAGINATION
======================================== */
.pagination-nav {
    margin-top: 20px;
}

.pagination {
    display: flex;
    list-style: none;
    gap: 5px;
    justify-content: center;
}

.pagination li a {
    display: block;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.pagination li a:hover {
    background: var(--bg);
}

.pagination li.active a {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ========================================
   UTILITIES
======================================== */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .detail-row-top {
        grid-template-columns: 1fr;
    }
    
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .actions-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .action-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .actions-danger {
        margin-left: 0;
        margin-top: 10px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
        gap: 15px;
    }
    
    .filter-form {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   MODAL
======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-lg {
    max-width: 800px;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ========================================
   FORM ENHANCEMENTS
======================================== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.permission-category {
    background: var(--bg);
    padding: 15px;
    border-radius: var(--radius-sm);
}

.permission-category h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--primary-dark);
}

/* ========================================
   PAGE ACTIONS
======================================== */
.page-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

/* ========================================
   BUTTON GROUP
======================================== */
.btn-group {
    display: flex;
    gap: 5px;
}

/* ========================================
   EDIT GRID
======================================== */
.edit-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .edit-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   USER LIST
======================================== */
.user-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.user-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.user-list li:last-child {
    border-bottom: none;
}

/* ========================================
   ACTIVITY LIST
======================================== */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

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

.activity-action-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    background: var(--bg);
}

.action-login { background: #d4edda; color: #155724; }
.action-logout { background: #e9ecef; color: #495057; }
.action-login_failed { background: #f8d7da; color: #721c24; }

/* ========================================
   INACTIVE ROW
======================================== */
.row-inactive {
    opacity: 0.6;
    background: #f8f9fa;
}

/* ========================================
   D-BLOCK HELPER
======================================== */
.d-block {
    display: block;
}

/* ========================================
   ACTION FORM
======================================== */
.action-form {
    margin-bottom: 10px;
}

.action-form:last-child {
    margin-bottom: 0;
}
