/* ===== TRỢ LÝ TUYÊN HUẤN SỐ - STYLE CHUYÊN NGHIỆP ===== */

:root {
    --primary-red: #c8102e;
    --primary-red-dark: #8b0000;
    --primary-red-light: #e63946;
    --accent-gold: #ffcd00;
    --accent-gold-light: #ffe066;
    --text-dark: #1e1e1e;
    --text-secondary: #6c757d;
    --bg-light: #f4f6f9;
    --bg-white: #ffffff;
    --border-light: #e9ecef;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.15);
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
}

/* Auth Pages Background */
.auth-bg {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-red-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.auth-bg::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 70%);
    animation: rotate 60s linear infinite;
    pointer-events: none;
}

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

.auth-container {
    width: 100%;
    max-width: 480px;
    position: relative;
    z-index: 1;
}

.auth-card {
    background: var(--bg-white);
    border-radius: 24px;
    padding: 40px 35px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.animate-fade-in {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo-wrapper {
    margin-bottom: 5px;
}

.auth-logo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-gold);
    padding: 3px;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s;
}

.auth-logo:hover {
    transform: scale(1.02);
}

.auth-title {
    color: var(--primary-red);
    font-size: 1.6rem;
    letter-spacing: -0.5px;
    text-transform: uppercase;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.05);
}

/* Form Controls */
.form-label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.input-group-text {
    background-color: var(--bg-light);
    border: 1px solid var(--border-light);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--text-secondary);
}

.form-control {
    border: 1px solid var(--border-light);
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 10px 15px 10px 10px;
    font-size: 1rem;
    transition: all 0.2s;
    background-color: white;
}

.form-control:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
    outline: none;
}

.input-group .form-control {
    border-left: none;
}

.input-group .btn-outline-secondary {
    border: 1px solid var(--border-light);
    border-left: none;
    border-radius: 0 8px 8px 0;
    background-color: white;
    color: var(--text-secondary);
}

.input-group .btn-outline-secondary:hover {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-red-dark) 100%);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 20px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-red-dark) 0%, #6d0000 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(200, 16, 46, 0.4);
    color: white;
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.3);
}

.btn-outline-secondary {
    border-color: var(--border-light);
    color: var(--text-secondary);
    border-radius: 0 8px 8px 0;
}

.btn-outline-secondary:hover {
    background-color: var(--bg-light);
    border-color: var(--border-light);
    color: var(--text-dark);
}

/* Links */
a {
    color: var(--primary-red);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-red-dark);
    text-decoration: underline;
}

/* Alerts */
.alert {
    border-radius: 8px;
    padding: 12px 16px;
    border: none;
    font-weight: 500;
}

.alert-danger {
    background-color: #fff5f5;
    color: #b91c1c;
    border-left: 4px solid #dc2626;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border-left: 4px solid #16a34a;
}

/* Divider */
hr {
    opacity: 0.5;
    border-top: 1px solid var(--border-light);
}

/* Main Layout (Dashboard) */
.app-header {
    background: linear-gradient(135deg, var(--primary-red), var(--primary-red-dark));
    color: white;
    padding: 0 30px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.sidebar {
    background: white;
    min-height: calc(100vh - 70px);
    box-shadow: var(--shadow-sm);
    border-right: 1px solid var(--border-light);
    padding: 20px 0;
}

.sidebar .nav-link {
    padding: 12px 20px;
    margin: 4px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .nav-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar .nav-link:hover {
    background-color: var(--bg-light);
    color: var(--primary-red);
}

.sidebar .nav-link.active {
    background: linear-gradient(135deg, #fff0f0 0%, #ffe5e5 100%);
    color: var(--primary-red);
    font-weight: 600;
    border-left: 4px solid var(--primary-red);
}

/* Cards */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s;
    overflow: hidden;
    background: white;
    border: 1px solid var(--border-light);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--primary-red);
    text-transform: uppercase;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 15px;
    border-bottom-width: 2px;
    border-color: var(--border-light);
    background-color: #fafafa;
}

.table td {
    padding: 15px;
    vertical-align: middle;
    border-color: var(--border-light);
}

/* Badges */
.badge {
    padding: 6px 10px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Utilities */
.text-danger {
    color: var(--primary-red) !important;
}

.text-warning {
    color: var(--accent-gold) !important;
}

.bg-danger {
    background-color: var(--primary-red) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .auth-card {
        padding: 30px 20px;
    }
    
    .auth-logo {
        width: 70px;
        height: 70px;
    }
    
    .auth-title {
        font-size: 1.4rem;
    }
}

/* ===== MOBILE OPTIMIZATION (max-width: 768px) ===== */
@media (max-width: 768px) {
    /* Tăng font chung cho dễ đọc */
    body {
        font-size: 15px;
    }

    /* Header thu nhỏ padding, logo nhỏ lại */
    .app-header {
        padding: 0 15px;
        height: 60px;
    }
    .app-header img {
        height: 35px !important;
    }
    .app-header h5 {
        font-size: 1rem;
    }
    .app-header small {
        display: none; /* Ẩn dòng phụ */
    }

    /* Dashboard container */
    .dashboard-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100% !important;
        min-height: auto;
        padding: 10px 0;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }
    .sidebar .nav {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }
    .sidebar .nav-link {
        padding: 8px 12px !important;
        margin: 2px !important;
        border-radius: 30px !important;
        border-left: none !important;
        background: #f8f9fa;
    }
    .sidebar .nav-link.active {
        background: var(--primary-red) !important;
        color: white !important;
    }
    .sidebar-header {
        padding: 10px 20px;
        text-align: center;
    }
    .user-info {
        justify-content: center;
    }

    /* Feature cards trên dashboard */
    .feature-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    .welcome-card {
        padding: 20px;
    }

    /* Admin page */
    .admin-wrapper {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }
    .admin-sidebar .nav-pills {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
    }
    .admin-sidebar .nav-link {
        padding: 8px 12px !important;
        margin: 3px !important;
        border-radius: 30px !important;
        border-left: none !important;
    }
    .admin-content {
        padding: 15px;
    }

    /* Writer & TTS 2-cột chuyển thành 1 cột */
    .writer-container,
    .tts-container {
        flex-direction: column;
    }
    .writer-sidebar,
    .tts-sidebar {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding: 15px;
    }
    .writer-main,
    .tts-main {
        padding: 15px;
    }

    /* Form controls to hơn */
    .form-control,
    .form-select,
    .btn {
        padding: 12px 15px !important;
        font-size: 16px !important; /* Tránh zoom trên iOS */
    }
    .input-group-text {
        padding: 12px 15px;
    }
    textarea.form-control {
        min-height: 120px;
    }

    /* Voice selector chiều cao giới hạn */
    .voice-selector {
        max-height: 250px;
    }

    /* Modal điều chỉnh */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    /* Table cho phép cuộn ngang nếu quá rộng */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* History tabs */
    .nav-tabs-custom .nav-link {
        padding: 10px 15px;
        font-size: 14px;
    }

    /* Ẩn avatar to trong sidebar nếu cần */
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* Nút Play/Download trong TTS to hơn */
    #ttsResult .btn {
        padding: 12px 16px !important;
    }

    /* Căn chỉnh lại padding chung */
    .card-body {
        padding: 15px;
    }
}