/**
 * FlitzService - Gemeinsame Styles
 * Version 1.0.0
 *
 * Dieses Stylesheet wird von allen Seiten verwendet
 * um Duplikation zu vermeiden und Caching zu verbessern.
 */

/* ============================================
   CSS VARIABLEN (Theme)
   ============================================ */
:root {
    /* Primaerfarben */
    --color-primary: #00d4ff;
    --color-secondary: #00ff88;
    --color-error: #ff4444;
    --color-warning: #ffaa00;

    /* Hintergruende */
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --bg-card: rgba(255,255,255,0.05);
    --bg-input: rgba(0,0,0,0.3);

    /* Text */
    --text-primary: #fff;
    --text-secondary: #888;
    --text-muted: #666;

    /* Borders */
    --border-light: rgba(255,255,255,0.1);
    --border-medium: rgba(255,255,255,0.2);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    --gradient-bg: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 50%, var(--bg-light) 100%);

    /* Schatten */
    --shadow-glow: 0 5px 20px rgba(0,212,255,0.3);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    /* Border Radius */
    --radius-small: 4px;
    --radius-medium: 8px;
    --radius-large: 12px;
    --radius-xl: 15px;
}

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

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

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1 {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-medium);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-normal);
}

.btn:hover:not(:disabled) {
    opacity: 0.8;
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--bg-dark);
    font-weight: bold;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.btn-full {
    width: 100%;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 25px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--color-primary);
}

/* ============================================
   FORMS
   ============================================ */
input[type="text"],
input[type="password"],
select {
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-small);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    transition: border-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
}

input::placeholder {
    color: var(--text-muted);
}

input.changed {
    border-color: var(--color-secondary);
    background: rgba(0,255,136,0.1);
}

select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-large);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.table-scroll {
    overflow-x: auto;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

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

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

th {
    background: rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 600;
    color: var(--color-primary);
}

tr:hover {
    background: var(--bg-card);
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-medium);
    font-size: 14px;
}

.status-text { color: var(--text-secondary); }
.status-saved { color: var(--color-secondary); }
.status-error { color: var(--color-error); }

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.connected { background: var(--color-secondary); }
.status-dot.disconnected { background: var(--color-error); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   STATUS BOXES
   ============================================ */
.status-box {
    padding: 15px;
    border-radius: var(--radius-medium);
    margin: 15px 0;
}

.status-box.connected {
    background: rgba(0,255,136,0.1);
    border: 1px solid rgba(0,255,136,0.3);
}

.status-box.disconnected {
    background: rgba(255,170,0,0.1);
    border: 1px solid rgba(255,170,0,0.3);
}

/* ============================================
   LOG CONTAINER
   ============================================ */
.log-container {
    background: #0a0a15;
    border-radius: var(--radius-medium);
    padding: 15px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
}

.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.log-entry .time {
    color: #555;
    margin-right: 8px;
}

.log-entry.cmd { color: var(--color-primary); }
.log-entry.success { color: var(--color-secondary); }
.log-entry.error { color: var(--color-error); }
.log-entry.warn { color: var(--color-warning); }
.log-entry.data { color: var(--text-secondary); }
.log-entry.info { color: var(--color-primary); }

/* ============================================
   SEARCH BOX
   ============================================ */
.search-box {
    padding: 10px 15px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-medium);
    color: var(--text-primary);
    font-size: 14px;
    width: 250px;
}

.search-box:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* ============================================
   ACTIONS
   ============================================ */
.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.actions .btn {
    flex: 1;
    min-width: 100px;
}

/* ============================================
   DELETE BUTTON
   ============================================ */
.delete-btn {
    background: transparent;
    border: none;
    color: var(--color-error);
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    transition: color var(--transition-fast);
}

.delete-btn:hover {
    color: #ff6666;
}

/* ============================================
   AUTH PROTECTION
   ============================================ */
.auth-pending .container,
.auth-pending .config-content,
.auth-pending main {
    display: none;
}

.auth-error {
    display: none;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
}

.auth-error h1 {
    color: var(--color-error);
    margin-bottom: 10px;
    -webkit-text-fill-color: var(--color-error);
}

.auth-error p {
    color: var(--text-secondary);
}

.auth-error a {
    color: var(--color-primary);
    margin-top: 20px;
    display: inline-block;
}

.auth-failed .auth-error {
    display: flex;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    border-radius: 26px;
    transition: var(--transition-normal);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: var(--transition-normal);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--gradient-primary);
}

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

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   MODALS
   ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

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

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

.modal-close:hover {
    color: var(--text-primary);
}

/* ============================================
   PROGRESS CIRCLE
   ============================================ */
.progress-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    color: var(--text-primary);
    position: relative;
}

.progress-circle span {
    position: absolute;
    width: 32px;
    height: 32px;
    background: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   FILE INPUT
   ============================================ */
.file-input {
    display: none;
}

.file-label {
    display: block;
    padding: 15px;
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-medium);
    text-align: center;
    cursor: pointer;
    margin: 15px 0;
    transition: all var(--transition-normal);
}

.file-label:hover {
    border-color: var(--color-primary);
    background: rgba(0,212,255,0.05);
}

.file-label.selected {
    border-color: var(--color-secondary);
    background: rgba(0,255,136,0.05);
}

/* ============================================
   DEVICE INFO GRID
   ============================================ */
.device-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.device-info-item {
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: var(--radius-medium);
}

.device-info-item .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.device-info-item .value {
    font-size: 0.9rem;
    margin-top: 3px;
    word-break: break-all;
}

.device-info-item.compatible .value {
    color: var(--color-secondary);
}

.device-info-item.incompatible {
    background: rgba(255,68,68,0.15);
    border: 1px solid rgba(255,68,68,0.3);
}

.device-info-item.incompatible .value {
    color: var(--color-error);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

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

.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
