/* Shared base and cross-page components. Loaded on every page. Rules that are
   unique to a single page live in pages/<page>/<page>.css. */

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

/* Auth pages opt into the system font stack. */
body.auth {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.app-title {
    margin: 10px 0 0 0;
    font-size: 2.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ---- Auth pages: login + register ---- */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    padding: 20px;
    text-align: center;
}

.login-logo {
    max-height: 53px;
    max-width: 100%;
    object-fit: contain;
    filter: brightness(1.1);
}

.login-content {
    padding: 20px;
}

.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-button {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-button:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46a3 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.login-button:active {
    transform: translateY(0);
}

.error-message {
    color: #f44336;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-height: 1.25em;
}

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

.create-account {
    color: #667eea;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.create-account:hover {
    color: #764ba2;
    text-decoration: underline;
}

@media (max-width: 480px) {
    .login-card {
        margin: 0;
        border-radius: 0;
    }

    .login-content {
        padding: 20px;
    }

    .login-logo {
        max-height: 100px;
    }
}

/* ---- Account pages: account + management ---- */

.account-container {
    max-width: 640px;
    margin: 0 auto;
}

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

.account-header img {
    height: 48px;
}

.back-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 14px;
    border-radius: 8px;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.35);
}

.account-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    padding: 20px 24px;
    margin-bottom: 18px;
}

.account-card h2 {
    font-size: 1.15em;
    color: #2c3e50;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.field-row {
    margin-bottom: 14px;
}

.field-row label {
    display: block;
    font-size: 0.85em;
    color: #6c757d;
    margin-bottom: 4px;
}

.field-row input[type="text"],
.field-row input[type="email"],
.field-row input[type="password"],
.field-row input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1em;
}

.field-row input:focus {
    outline: none;
    border-color: #667eea;
}

.primary-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn:hover {
    opacity: 0.92;
}

.danger-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
}

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

.device-meta {
    font-size: 0.8em;
    color: #6c757d;
}

.empty-state {
    color: #6c757d;
    font-style: italic;
    padding: 8px 0;
}

.status-message {
    margin-top: 10px;
    font-size: 0.9em;
    min-height: 1.2em;
}

.status-message.success {
    color: #27ae60;
}

.status-message.error {
    color: #e74c3c;
}

/* ---- Password show/hide control (injected on every page) ---- */

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
}

.password-toggle:hover {
    color: #667eea;
}

.password-toggle .icon-eye-off {
    display: none;
}

.password-toggle.revealed .icon-eye {
    display: none;
}

.password-toggle.revealed .icon-eye-off {
    display: block;
}

/* ---- Navigation busy indicator (injected on every page) ---- */

.busy-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
}

.busy-overlay.active {
    display: flex;
}

.busy-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: busy-spin 0.8s linear infinite;
}

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

/* ---- Modal dialog (the single shared component, js/Modal.js) ---- */

.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    z-index: 1100;
}

.modal-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-title {
    margin: 0;
    font-size: 1.15em;
    font-weight: 600;
    color: #2c3e50;
}

.modal-title:empty {
    display: none;
}

.modal-close {
    font-size: 1.6em;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
}

.modal-close:hover {
    color: #2c3e50;
}

/* The body is the only scrolling region, so a tall dialog never pushes its
   header or footer off screen. */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    color: #444;
    line-height: 1.5;
}

.modal-body p {
    margin: 0 0 12px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body ol,
.modal-body ul {
    margin: 0 0 12px 1.2em;
}

.modal-body code {
    background: #f4f6fb;
    border-radius: 6px;
    padding: 2px 6px;
    font-family: monospace;
}

.modal-body pre {
    background: #f4f6fb;
    border-radius: 8px;
    padding: 12px;
    margin: 0 0 12px;
    font-family: monospace;
    font-size: 0.85em;
    line-height: 1.4;
    overflow-x: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn.modal-hidden {
    display: none;
}

.modal-cancel {
    background: #6c757d;
    color: white;
}

.modal-cancel:hover {
    background: #5a6268;
}

.modal-confirm {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-confirm:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46a3 100%);
}

.modal-confirm:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.5;
}

.modal-confirm.modal-danger {
    background: #e74c3c;
}

.modal-confirm.modal-danger:hover {
    background: #c0392b;
}
