/* ==========================================================================
   Ekkora — Admin Portal Styles
   ========================================================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f3f4f6;
    color: #1f2937;
    line-height: 1.5;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.admin-header {
    background: #1e40af;
    color: #fff;
    padding: 1rem 0;
}

.admin-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h1 {
    font-size: 1.25rem;
}

.admin-header nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 0.9rem;
}

.admin-header nav a {
    color: #bfdbfe;
    text-decoration: none;
}

.admin-header nav a:hover {
    color: #fff;
}

/* Main */
.admin-main {
    padding: 2rem 0;
}

.admin-main h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card h3 {
    margin-bottom: 0.75rem;
}

.card p {
    margin-bottom: 0.5rem;
}

.card-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* URL rows with copy buttons */
.url-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.95rem;
}

.url-row a {
    color: #2563eb;
    word-break: break-all;
}

/* Stats */
.stats-heading {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e40af;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* Forms */
fieldset {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: #fff;
}

legend {
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0 0.5rem;
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="time"],
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
    border-color: #2563eb;
}

.form-group input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
}

.form-group input[type="file"] {
    font-size: 0.9rem;
}

.form-group small {
    display: block;
    color: #6b7280;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 120px;
}

/* Logo upload */
.logo-manager {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.logo-frame {
    width: 96px;
    height: 96px;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-preview {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-actions {
    display: flex;
    gap: 0.5rem;
}

.logo-remove-status {
    display: none;
    font-size: 0.75rem;
    color: #dc2626;
    font-style: italic;
}

.logo-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1.25rem 2rem;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    cursor: pointer;
    text-align: center;
    width: 100%;
    max-width: 260px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.logo-dropzone:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.logo-dropzone-selected {
    border-color: #2563eb;
    background: #eff6ff;
}

.logo-dropzone-icon {
    color: #9ca3af;
    margin-bottom: 0.25rem;
}

.logo-dropzone-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
}

.logo-dropzone-hint {
    font-size: 0.7rem;
    color: #9ca3af;
}

.logo-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Small button variants */
.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 5px;
}

.btn-outline {
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-outline:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.btn-danger-outline {
    background: #ffffff;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.btn-danger-outline:disabled {
    color: #9ca3af;
    border-color: #e5e7eb;
    background: #f9fafb;
    cursor: default;
    opacity: 0.8;
    font-size: 0.7rem;
}

/* Color pickers — descriptive layout */
.color-pickers {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.color-picker-group {
    flex: 1;
    min-width: 160px;
}

.color-picker-group label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    background: #f9fafb;
    transition: border-color 0.15s ease;
}

.color-picker-group label:hover {
    border-color: #2563eb;
}

.color-picker-group input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 2px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.color-picker-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.color-picker-info strong {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
}

.color-picker-info small {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0;
}

/* Dark mode toggle */
.dark-mode-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.dark-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.dark-mode-toggle small {
    color: #6b7280;
    font-size: 0.75rem;
    margin-left: 1.6rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: opacity 0.15s;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

.btn-copy {
    background: #dbeafe;
    color: #1e40af;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.tile-count {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 500;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f3f4f6;
}

.login-container {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #1e40af;
}

.login-container .btn {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

/* Password visibility toggle */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    width: 100%;
    padding: 0.5rem 2.75rem 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.password-wrapper input:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
    border-color: #2563eb;
}

.btn-eye {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 0.25rem;
    display: flex;
    align-items: center;
}

.btn-eye:hover {
    color: #1f2937;
}

/* Fieldset hint text */
.fieldset-hint {
    display: block;
    color: #6b7280;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

/* Tile visibility toggle grid */
.toggle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.toggle-grid label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 400;
    font-size: 0.95rem;
}

.toggle-grid label:hover {
    background: #f3f4f6;
}

.tile-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

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

/* ==========================================================================
   Settings Page — Modern Card Layout
   ========================================================================== */

.settings-section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.section-hint {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 1.25rem;
}

/* Settings cards (General Settings section) */
.settings-card {
    background: #ffffff;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
}

.settings-card .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
}

.settings-card .card-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

/* Tile Configuration Cards */
.tile-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tile-card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    border-left: 4px solid var(--tile-accent, #6b7280);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.tile-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
}

.tile-card-identity {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.tile-card-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tile-accent);
    flex-shrink: 0;
}

.tile-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.tile-card-type {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    background: #e5e7eb;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.tile-card-body {
    padding: 1rem 1.25rem;
}

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

.tile-card-body .form-group:last-child {
    margin-bottom: 0;
}

.tile-card-note {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    font-style: italic;
    margin-top: 0.25rem;
}

/* Toggle Switch */
.tile-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

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

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: #d1d5db;
    border-radius: 11px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.tile-toggle input:checked + .toggle-slider {
    background: var(--tile-accent, #2563eb);
}

.tile-toggle input:checked + .toggle-slider::after {
    transform: translateX(18px);
}

.tile-toggle input:focus-visible + .toggle-slider {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.toggle-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #6b7280;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .toggle-slider,
    .toggle-slider::after,
    .tile-card,
    .color-picker-group label,
    .logo-dropzone {
        transition-duration: 0.01ms !important;
    }
}

/* Responsive — settings page */
@media (max-width: 600px) {
    .color-pickers {
        flex-direction: column;
    }

    .color-picker-group {
        min-width: 100%;
    }

    .tile-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .tile-card-body .form-row {
        flex-direction: column;
    }

    .tile-card-body .form-row .form-group {
        min-width: 100%;
    }

    .settings-card .form-row {
        flex-direction: column;
    }

    .settings-card .form-row .form-group {
        min-width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        text-align: center;
    }

    .admin-header .container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .admin-header nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }
}

@media (max-width: 400px) {
    .tile-card-body {
        padding: 0.75rem;
    }

    .tile-card-header {
        padding: 0.75rem;
    }
}
