/* --- CSS Variables & Theme --- */
:root {
    --primary: #D7191E;
    --primary-hover: #B7151B;
    --primary-light: #F5EEE6;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg-main: #F3F4F6; /* Light gray background */
    --bg-surface: #FFFFFF; /* Pure white surface */
    --bg-surface-hover: #F9FAFB; /* Slightly off-white for hover */
    
    --text-primary: #111827; /* Near black text */
    --text-secondary: #4B5563; /* Medium gray */
    --text-muted: #9CA3AF; /* Light gray */
    
    --border-color: #E5E7EB; /* Subtle light borders */
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
}

/* Typography */
b, strong { font-weight: 500; }
h1, h2, h3, h4 { color: var(--text-primary); font-weight: 600; }
a { color: #000000; text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }

/* --- Utility Classes --- */
.view {
    display: none;
    height: 100vh;
    width: 100vw;
}
.view.active {
    display: flex;
}
.mb-4 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* --- Buttons & Inputs --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.input-icon {
    position: relative;
}
.input-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.input-icon input {
    padding-left: 2.75rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
    background-color: var(--bg-surface);
    color: var(--text-primary);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* --- Login View --- */
.login-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
}
.login-card {
    width: 100%;
    max-width: 480px;
    margin: auto;
    padding: 3rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-header .logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}
.login-header .community-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 1.25rem;
}
/* login logo: wide and centered */
.login-header .community-brand img {
    width: 240px;
    max-width: 100%;
    height: auto;
    display: block;
}
/* login name without logo: large prominent text */
.login-header .community-brand span {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}
.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}
.login-hint {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.75rem;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
}

.login-decoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}
.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.15;
    border-radius: 50%;
}
.shape-1 {
    top: -10%;
    right: -5%;
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
}
.shape-2 {
    bottom: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, #10B981, #3B82F6);
}

/* --- Dashboard Layout --- */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.sidebar .logo {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.community-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    overflow: hidden;
}
/* sidebar logo: 80% of the logo area width, auto height */
.community-brand img {
    width: 80%;
    max-width: 80%;
    height: auto;
    flex-shrink: 0;
    object-fit: contain;
}
/* sidebar name without logo: larger readable text */
.community-brand span {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}
.sidebar-nav-fixed {
    flex: 0 0 auto;
    padding: 1.5rem 1rem 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}
.nav-item i {
    font-size: 1.25rem;
}
.nav-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--primary-light);
    color: #000000;
}
.nav-item.locked {
    opacity: 0.6;
    background: transparent;
    cursor: not-allowed;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}
.user-info .details {
    display: flex;
    flex-direction: column;
}
.user-info .name {
    font-size: 0.875rem;
    font-weight: 600;
}
.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.topbar {
    height: 70px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}
.topbar h2 {
    font-size: 1.25rem;
}

.scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* --- Admin Views --- */
.admin-section {
    display: none;
}
.admin-section.active {
    display: block;
}

/* Phase Cards */
.phase-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.phase-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--bg-surface-hover);
}
.phase-card-title h3 {
    margin-bottom: 0.25rem;
}
.phase-card-title p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.phase-rule-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary-light);
    color: #000000;
    font-size: 0.75rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-weight: 500;
}

.task-list {
    padding: 1rem 1.5rem;
}
.task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--bg-main);
}
.task-item:last-child {
    margin-bottom: 0;
}

/* Mentee Progress Cards */
.user-progress-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.user-progress-info h4 {
    margin-bottom: 0.5rem;
}
.user-progress-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.progress-bar-container {
    width: 200px;
}

/* --- Mentee Views --- */
.phase-container {
    max-width: 800px;
    margin: 0 auto;
}
.phase-hero {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}
.phase-hero h1 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}
.phase-hero p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.progress-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}
.progress-track {
    height: 8px;
    background: var(--bg-main);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.5s ease-in-out;
}

.mentee-task-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.mentee-task-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    cursor: pointer;
    transition: var(--transition);
}
.mentee-task-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}
.mentee-task-item.completed {
    opacity: 0.8;
    background: var(--bg-main);
}
.mentee-task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.checkbox-custom {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: var(--transition);
    flex-shrink: 0;
}
.mentee-task-item.completed .checkbox-custom {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.locked-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}
.locked-state i {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* --- Modals --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 40;
    display: none;
}
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 100%;
    max-width: 500px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: none;
    opacity: 0;
    transition: all 0.2s ease-in-out;
}
.modal.show {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.modal-backdrop.show {
    display: block;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body {
    padding: 1.5rem;
    max-height: calc(80vh - 70px);
    overflow-y: auto;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.settings-group {
    background: var(--bg-main);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
}
.settings-group h4 {
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(100%);
    opacity: 0;
    animation: toast-in 0.3s forwards;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

@keyframes toast-in {
    to { transform: translateY(0); opacity: 1; }
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--danger);
    transition: 0.3s;
    border-radius: 24px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
    background-color: var(--success);
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* --- Badges --- */
.badge {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.15rem 0.4rem;
    border-radius: 12px;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
}

/* --- Chat System --- */
.msg-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    position: relative;
    word-wrap: break-word;
    font-size: 0.875rem;
}

.msg-sent {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.msg-received {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.msg-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    gap: 1rem;
    opacity: 0.8;
}

.msg-task-link {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    background: rgba(0,0,0,0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.9;
}
.msg-task-link:hover {
    color: inherit;
    opacity: 1;
}

.chat-user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}
.chat-user-item:hover {
    background: var(--bg-surface-hover);
}
.chat-user-item.active {
    background: var(--primary-light);
    color: #000000;
}

.chat-user-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.chat-user-item-name {
    font-weight: 600;
    font-size: 0.875rem;
}
.chat-user-item-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* Responsive */
@media (max-width: 768px) {
    .view { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border-color); }
    .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 1rem; }
    .nav-item { white-space: nowrap; }
    .sidebar-footer { display: none; }
    .topbar { padding: 0 1rem; }
    .scroll-area { padding: 1rem; }
}

/* --- Quill Content Fixes --- */
.modal-quill-content ul, .modal-quill-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}
.modal-quill-content li {
    margin-bottom: 0.25rem;
}
.modal-quill-content p:last-child, .modal-quill-content ul:last-child, .modal-quill-content ol:last-child {
    margin-bottom: 0;
}
.modal-quill-content a {
    color: var(--primary);
    text-decoration: underline;
}
