/**
 * Telemaco Assistant - Autenticazione Styles
 * ==========================================
 * Foglio di stile comune per pagine di autenticazione.
 *
 * Autore: Telemaco Srl
 * Versione: 1.0
 */

/* ============================================================================
   Reset e Base
   ============================================================================ */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a237e 0%, #3949ab 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   Layout Containers
   ============================================================================ */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 480px;
    padding: 48px 40px;
}

.auth-card.large {
    max-width: 700px;
}

/* ============================================================================
   Header
   ============================================================================ */

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    color: #1a237e;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-header p {
    color: #666;
    font-size: 15px;
}

/* ============================================================================
   Navigation
   ============================================================================ */

.auth-nav {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 32px;
}

.auth-nav-item {
    flex: 1;
    padding: 16px;
    text-align: center;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-weight: 500;
}

.auth-nav-item:hover {
    color: #1a237e;
}

.auth-nav-item.active {
    color: #1a237e;
    border-bottom-color: #1a237e;
}

/* ============================================================================
   Forms
   ============================================================================ */

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

.form-group label {
    display: block;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s;
    outline: none;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #1a237e;
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.form-group input::placeholder {
    color: #999;
}

.form-group input:disabled,
.form-group select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.form-group small {
    display: block;
    color: #666;
    font-size: 12px;
    margin-top: 6px;
}

.form-group small.error {
    color: #c62828;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #1a237e;
    color: white;
}

.btn-primary:hover {
    background: #3949ab;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(26, 35, 126, 0.3);
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #c62828;
    color: white;
}

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

.btn-success {
    background: #2e7d32;
    color: white;
}

.btn-success:hover {
    background: #43a047;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-block {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* ============================================================================
   Alerts
   ============================================================================ */

.alert {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.alert.show {
    display: block;
}

.alert.error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #c62828;
}

.alert.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #2e7d32;
}

.alert.info {
    background: #e3f2fd;
    color: #1565c0;
    border-left: 4px solid #1565c0;
}

.alert.warning {
    background: #fff3e0;
    color: #e65100;
    border-left: 4px solid #e65100;
}

/* ============================================================================
   Cards
   ============================================================================ */

.card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a237e;
}

.card-body {
    color: #666;
    line-height: 1.6;
}

/* ============================================================================
   Tables
   ============================================================================ */

.table-container {
    overflow-x: auto;
}

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

.table thead {
    background: #f5f6ff;
}

.table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #1a237e;
    font-size: 14px;
    border-bottom: 2px solid #e0e0e0;
}

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

.table tbody tr:hover {
    background: #f9f9f9;
}

/* ============================================================================
   Badges
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-warning {
    background: #fff3e0;
    color: #e65100;
}

.badge-danger {
    background: #ffebee;
    color: #c62828;
}

.badge-info {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-primary {
    background: #f5f6ff;
    color: #1a237e;
}

/* ============================================================================
   QR Code Display
   ============================================================================ */

.qr-container {
    text-align: center;
    padding: 32px;
    background: #f9f9f9;
    border-radius: 12px;
    margin: 24px 0;
}

.qr-code {
    width: 200px;
    height: 200px;
    margin: 0 auto 16px;
    background: white;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.qr-code img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.qr-instructions {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.secret-code {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    margin-top: 16px;
    word-break: break-all;
    user-select: all;
}

/* ============================================================================
   Backup Codes
   ============================================================================ */

.backup-codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.backup-code {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-align: center;
    user-select: all;
    border: 1px dashed #ccc;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

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

.text-muted {
    color: #999;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ============================================================================
   Shared Header & User Menu
   ============================================================================ */

.chat-header {
    background: #1a237e;
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0;
    color: white;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-link {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.help-link:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.help-link i {
    font-size: 18px;
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* User Menu */
.user-menu {
    position: relative;
    display: block;
}

.user-menu-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 240px;
    overflow: hidden;
    display: none;
    z-index: 1000;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    text-align: left;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
}

.user-dropdown-item:hover {
    background: #f5f6ff;
    color: #1a237e;
}

.user-dropdown-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 8px 0;
}

.user-dropdown-section-title {
    padding: 8px 20px;
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    font-weight: 600;
}

.badge-2fa {
    background: #2e7d32;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}

/* ============================================================================
   SmartComM Footer Styles
   ============================================================================ */

.smartcomm-footer {
    background: white;
    padding: 64px 24px;
    width: 100%;
    margin-top: auto;
    border-top: 1px solid #e0e0e0;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-title {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 32px;
}

.footer-description-box {
    max-width: 800px;
    margin: 0 auto 48px;
}

.footer-description {
    color: #4b5563;
    font-size: 18px;
    line-height: 1.625;
}

.footer-image-box {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.footer-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.footer-btn {
    display: inline-flex;
    align-items: center;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    color: white;
    background-color: #17a2b8;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.2s;
    gap: 8px;
}

.footer-btn:hover {
    background-color: #138496;
}

.footer-btn svg {
    width: 20px;
    height: 20px;
}

/* Ensure body can scroll when footer is present */
body {
    display: flex;
    flex-direction: column;
}

body.has-header {
    overflow-y: auto !important;
}

/* Body override for index.html */
body.main-chat {
    overflow-y: auto;
}



/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 640px) {
    .auth-card {
        padding: 32px 24px;
    }

    .auth-card.large {
        max-width: 100%;
    }

    .backup-codes {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}
