/* PWA BNO Styles - iOS-optimiert */

:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-radius: 12px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --safe-area-inset-top: env(safe-area-inset-top);
    --safe-area-inset-bottom: env(safe-area-inset-bottom);
}

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

/* Accessibility - Screen reader only */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus indicators for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding-top: var(--safe-area-inset-top);
    padding-bottom: var(--safe-area-inset-bottom);
}

/* iOS Standalone Mode Anpassungen */
body.ios-standalone {
    padding-top: 20px;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}

.app-header h1 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 10px;
}

.install-badge {
    margin-top: 15px;
}

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

.card h2 {
    color: var(--dark-color);
    font-size: 20px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: var(--light-color);
    border-radius: 8px;
}

.status-label {
    font-weight: 600;
    color: var(--dark-color);
}

.status-value {
    color: var(--primary-color);
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.95);
}

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

.btn-primary:hover {
    background: #0056b3;
}

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

.btn-success:hover {
    background: #218838;
}

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

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

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

.btn-secondary:hover {
    background: #23272b;
}

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

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

/* Form Elements */
.input-field, .select-field {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    -webkit-appearance: none;
}

.input-field:focus, .select-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

textarea.input-field {
    min-height: 80px;
    resize: vertical;
}

/* Messages */
.message {
    padding: 10px;
    margin: 10px 0;
    border-radius: 8px;
    display: none;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

/* Privacy Section */
.privacy-info ul {
    list-style-position: inside;
    margin: 15px 0;
}

.privacy-info li {
    padding: 5px 0;
}

.privacy-controls {
    margin-top: 20px;
    padding: 15px;
    background: var(--light-color);
    border-radius: 8px;
}

.privacy-controls code {
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary-color);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 20px;
    color: white;
    margin-top: 40px;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--warning-color);
    color: var(--dark-color);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
    }
    to {
        transform: translateX(-50%) translateY(0);
    }
}

/* 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: 2000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    max-width: 400px;
    width: 100%;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h3 {
    margin-bottom: 15px;
    color: var(--dark-color);
}

.modal-content ol {
    margin: 20px 0;
    padding-left: 20px;
}

.modal-content li {
    margin: 10px 0;
}

.icon-share {
    display: inline-block;
    padding: 2px 6px;
    background: var(--light-color);
    border-radius: 4px;
}

/* Analytics Summary */
.summary-content {
    margin-top: 15px;
    padding: 15px;
    background: var(--light-color);
    border-radius: 8px;
    font-family: monospace;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* Responsive Design */
@media (min-width: 768px) {
    .status-grid {
        grid-template-columns: 1fr 1fr;
    }

    .push-controls {
        display: flex;
        gap: 10px;
    }

    .analytics-controls {
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .analytics-controls .select-field {
        width: auto;
        margin: 0;
    }
}

/* iOS-spezifische Anpassungen */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    .btn {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
    }

    input, textarea {
        font-size: 16px; /* Verhindert Zoom bei Focus */
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 123, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============= Account & Sync Styles ============= */

.account-section {
    margin-bottom: 20px;
}

.auth-form {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

.auth-form h3 {
    margin-bottom: 15px;
    color: white;
}

.auth-form .input-field {
    width: 100%;
    margin-bottom: 12px;
}

.form-link {
    margin-top: 15px;
    text-align: center;
    color: white;
}

.form-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.form-link a:hover {
    text-decoration: underline;
}

.password-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
}

.user-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.user-info p {
    margin: 8px 0;
    color: white;
}

.user-info span {
    color: rgba(255, 255, 255, 0.9);
}

.sync-controls {
    margin: 20px 0;
}

.sync-controls h3 {
    color: white;
    margin-bottom: 15px;
}

.sync-controls .btn {
    margin-right: 10px;
    margin-bottom: 10px;
}

.sync-status {
    padding: 12px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    font-weight: 500;
}

.sync-status-info {
    background: rgba(0, 123, 255, 0.2);
    color: white;
}

.sync-status-success {
    background: rgba(40, 167, 69, 0.2);
    color: white;
}

.sync-status-error {
    background: rgba(220, 53, 69, 0.2);
    color: white;
}

.devices-container {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

.devices-container h3 {
    color: white;
    margin-bottom: 15px;
}

.devices-list {
    list-style: none;
    padding: 0;
}

.device-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.device-info strong {
    color: white;
    font-size: 16px;
}

.device-info span {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.message-info {
    background: rgba(0, 123, 255, 0.2);
    color: white;
}

.message-success {
    background: rgba(40, 167, 69, 0.2);
    color: white;
}

.message-error {
    background: rgba(220, 53, 69, 0.2);
    color: white;
}

/* Responsive adjustments for auth section */
@media (min-width: 768px) {
    .auth-form {
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }

    .sync-controls .btn {
        display: inline-block;
    }
}

/* ============= Device Status Table Styles ============= */

.registered-devices-section {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
}

.registered-devices-section h3 {
    color: var(--dark-color);
    font-size: 18px;
    margin-bottom: 15px;
}

.devices-status-container {
    overflow-x: auto;
}

.device-info-message {
    text-align: center;
    color: #666;
    padding: 20px;
    font-style: italic;
}

.devices-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.devices-table thead {
    background: var(--primary-color);
    color: white;
}

.devices-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.devices-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

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

.devices-table tbody tr:hover {
    background: var(--light-color);
}

.device-row.current-device {
    background: rgba(0, 123, 255, 0.05);
}

.device-row.current-device:hover {
    background: rgba(0, 123, 255, 0.1);
}

.device-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.device-status.active {
    background: rgba(40, 167, 69, 0.2);
    color: var(--success-color);
}

.device-status.inactive {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger-color);
}

/* Responsive table for mobile */
@media (max-width: 768px) {
    .devices-table {
        font-size: 12px;
    }

    .devices-table th,
    .devices-table td {
        padding: 8px 6px;
    }

    .devices-table th {
        font-size: 11px;
    }

    /* Hide less important columns on mobile */
    .devices-table th:nth-child(3),
    .devices-table td:nth-child(3) {
        display: none;
    }
}