/* =============================================
   SURVEY SYSTEM - STYLESHEET
   Color: #0066b2 | Font: Times New Roman
   ============================================= */

:root {
    --primary: #0066b2;
    --primary-dark: #004d87;
    --primary-light: #e0f0ff;
    --primary-lighter: #f0f7ff;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --border-color: #d1d5db;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Times New Roman', Times, serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary-dark); }

/* === LAYOUT === */
.wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    padding: 18px 20px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.sidebar-nav { padding: 10px 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-family: 'Segoe UI', Arial, sans-serif;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav .nav-section {
    padding: 14px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.45);
    font-weight: 600;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    padding: 12px 28px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-600);
    font-size: 14px;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.content-area { padding: 22px 28px; }

/* === AUTH PAGES === */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #004d87 100%);
    padding: 20px;
}

.auth-box {
    background: #fff;
    border-radius: 10px;
    padding: 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.auth-box h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: var(--primary); }
.auth-box .subtitle { color: var(--gray-500); margin-bottom: 24px; font-size: 14px; }

/* === CARDS === */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50);
}

.card-header h2 { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.card-body { padding: 18px; }

/* === STAT CARDS === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}

.stat-icon.blue   { background: #0066b2; }
.stat-icon.green  { background: #16a34a; }
.stat-icon.yellow { background: #f59e0b; }
.stat-icon.red    { background: #dc2626; }
.stat-icon.cyan   { background: #0891b2; }

.stat-info .stat-value { font-size: 24px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.stat-info .stat-label { font-size: 13px; color: var(--gray-500); font-family: 'Segoe UI', Arial, sans-serif; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
    color: #444;
    font-size: 14px;
}

.form-group label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #d1d1d1;
    border-radius: 3px;
    font-size: 15px;
    color: #444;
    background: rgba(255, 255, 255, 0.95);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: 'Times New Roman', Times, serif;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0,102,178,0.12);
}

textarea.form-control { min-height: 70px; resize: vertical; }
select.form-control { cursor: pointer; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px; height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-check label { font-weight: 400; cursor: pointer; margin-bottom: 0; }

.form-inline { display: flex; gap: 10px; align-items: end; }
.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 3px; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    border: none;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: 'Segoe UI', Arial, sans-serif;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; opacity: 0.9; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }

.btn-outline {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* === TABLES === */
.table-wrap { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; }

table.data-table th {
    background: var(--primary-lighter);
    padding: 9px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    color: var(--primary-dark);
    border-bottom: 2px solid var(--primary);
    white-space: nowrap;
    font-family: 'Segoe UI', Arial, sans-serif;
}

table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

table.data-table tr:hover td { background: var(--primary-lighter); }

/* Matrix table in survey */
.question-card table.data-table td:first-child { min-width: 160px; font-weight: 600; font-size: 14px; }
.question-card table.data-table th { white-space: normal; text-align: center; min-width: 80px; line-height: 1.3; }

/* Matrix radio buttons - larger & touch friendly */
.question-card table.data-table input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border: 2px solid #c0c8d0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: #fff;
    vertical-align: middle;
}

.question-card table.data-table input[type="radio"]:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,102,178,0.1);
}

.question-card table.data-table input[type="radio"]:checked {
    border-color: var(--primary);
    background: var(--primary);
}

.question-card table.data-table input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
}

/* General form radio & checkbox larger */
.form-check input[type="radio"],
.form-check input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #c0c8d0;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: #fff;
    flex-shrink: 0;
}

.form-check input[type="radio"] { border-radius: 50%; }
.form-check input[type="checkbox"] { border-radius: 4px; }

.form-check input[type="radio"]:checked,
.form-check input[type="checkbox"]:checked {
    border-color: var(--primary);
    background: var(--primary);
}

.form-check input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
}

.form-check input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-info    { background: var(--info-light); color: var(--info); }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* === ALERTS === */
.alert {
    padding: 10px 14px;
    border-radius: 3px;
    margin-bottom: 14px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-light); color: #166534; border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-light); color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400e; border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-light); color: #155e75; border-left: 4px solid var(--info); }

/* === PAGE HEADER === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-header h1 { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.page-header .breadcrumb { font-size: 13px; color: var(--gray-400); margin-top: 3px; }

/* === TABS === */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    gap: 0;
    margin-bottom: 18px;
}

.tabs a {
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.tabs a:hover { color: var(--gray-700); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === SURVEY RESPONSE UI === */
.survey-header {
    background: linear-gradient(135deg, var(--primary) 0%, #004d87 100%);
    color: #fff;
    padding: 36px 28px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.survey-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.survey-header p { opacity: 0.85; font-size: 15px; }

.question-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.question-card .q-number {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 4px;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.question-card .q-text { font-size: 16px; font-weight: 700; color: #333; margin-bottom: 3px; }
.question-card .q-help { font-size: 13px; color: var(--gray-400); margin-bottom: 12px; }
.question-card .q-required { color: var(--danger); font-weight: 700; }

/* NPS Scale */
.nps-group { display: flex; gap: 4px; flex-wrap: wrap; }
.nps-group label {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-weight: 700; cursor: pointer;
    transition: all 0.2s; font-size: 14px;
}
.nps-group input { display: none; }
.nps-group input:checked + label { background: var(--primary); border-color: var(--primary); color: #fff; }
.nps-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* Likert */
.likert-group { display: flex; gap: 10px; flex-wrap: wrap; }
.likert-group label {
    flex: 1; min-width: 90px; text-align: center;
    padding: 9px 6px; border: 2px solid var(--gray-200);
    border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.2s;
}
.likert-group input { display: none; }
.likert-group input:checked + label { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 700; }

/* Yes/No */
.yesno-group { display: flex; gap: 10px; }
.yesno-group label {
    flex: 1; max-width: 150px; text-align: center;
    padding: 12px; border: 2px solid var(--gray-200);
    border-radius: 6px; cursor: pointer; font-size: 15px; font-weight: 700; transition: all 0.2s;
}
.yesno-group input { display: none; }
.yesno-group input:checked + label { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* === QUESTION BUILDER === */
.question-builder {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: #fff;
}

.question-builder-header {
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 14px;
}

.question-builder-body { padding: 14px; }

.option-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.option-row input { flex: 1; }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 50px 20px; color: var(--gray-400); }
.empty-state .icon { font-size: 44px; margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { font-size: 17px; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { max-width: 380px; margin: 0 auto 18px; font-size: 14px; }

/* === MODAL === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show { display: flex; }

.modal-box {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 580px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary-lighter);
}

.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--primary); }

.modal-close {
    background: none; border: none;
    font-size: 22px; cursor: pointer;
    color: var(--gray-400); padding: 4px;
}

.modal-body { padding: 22px; }

/* === UTILITIES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 14px; }
.mb-3 { margin-bottom: 22px; }
.d-flex { display: flex; }
.gap-2 { gap: 14px; }
.flex-1 { flex: 1; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .content-area { padding: 14px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .auth-box { padding: 22px; }
    .nps-group label { width: 34px; height: 34px; font-size: 12px; }
    .likert-group { flex-direction: column; }

    /* Matrix table mobile */
    .question-card .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .question-card table.data-table { min-width: 500px; }
    .question-card table.data-table td:first-child,
    .question-card table.data-table th:first-child {
        min-width: 180px;
        white-space: normal;
        position: sticky;
        left: 0;
        background: #fff;
        z-index: 1;
    }
    .question-card table.data-table th {
        white-space: normal;
        min-width: 70px;
        font-size: 12px;
        padding: 8px 6px;
    }
}

/* =============================================
   SECTION HEADER BLOCK
   ============================================= */
.section-header-block {
    background: #e8f0fe !important;
    border-left: 4px solid #4285f4 !important;
    border-radius: 6px;
}
.section-header-block .question-builder-header {
    padding: 12px 16px;
}

/* CKEditor overrides for inline usage */
.cke_chrome { border: 1px solid var(--gray-300) !important; border-radius: var(--radius) !important; }
.cke_top { background: var(--gray-50) !important; border-bottom: 1px solid var(--gray-200) !important; }
.cke_bottom { display: none !important; }

/* Question text HTML rendering in take survey */
.q-text p { margin: 0 0 4px 0; }
.q-text ul, .q-text ol { margin: 4px 0; padding-left: 20px; }

/* =============================================
   RESPONSIVE MOBILE / TABLET - take survey
   ============================================= */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0 !important; }
    .topbar { left: 0 !important; }
    .page-header { flex-direction: column; gap: 12px; }
    .page-header .btn-group { flex-wrap: wrap; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .d-flex { flex-direction: column; }
    .modal-box { width: 95vw !important; max-width: 95vw !important; margin: 10px auto; max-height: 90vh; }
    .question-builder-header { flex-direction: column; gap: 8px; }
    .question-builder-header .btn-group { flex-wrap: wrap; }
    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 6px 8px; }
}

/* Survey take page mobile */
@media (max-width: 600px) {
    .survey-container { padding: 0 8px !important; }
    .survey-header { padding: 20px 16px !important; border-radius: 8px !important; }
    .survey-header h1 { font-size: 20px !important; }
    .question-card { padding: 16px !important; margin-bottom: 12px !important; border-radius: 8px !important; }
    .q-text { font-size: 15px !important; }
    .q-number { font-size: 12px !important; }
    .form-control { font-size: 16px !important; /* prevent iOS zoom */ }
    .option-label { padding: 10px 12px !important; font-size: 14px !important; }
    .btn-lg { width: 100%; font-size: 16px !important; padding: 14px !important; }
    .survey-footer-submit { position: sticky; bottom: 0; background: #fff; padding: 12px 16px; border-top: 1px solid #e5e7eb; margin: 0 -8px; z-index: 10; }
    
    /* Touch-friendly radio/checkbox */
    input[type="radio"], input[type="checkbox"] {
        width: 20px; height: 20px; margin-right: 10px;
    }
    .option-label { min-height: 44px; display: flex; align-items: center; }
    
    /* Matrix table scroll */
    .matrix-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .matrix-table { min-width: 400px; }
    
    /* Ranking touch */
    .ranking-item { min-height: 44px; padding: 10px 12px !important; }
}

/* Tablet */
@media (min-width: 601px) and (max-width: 1024px) {
    .survey-container { max-width: 700px !important; }
    .question-card { padding: 20px !important; }
}
