/*
 ******************************************
 * @author Satheesh PM, BARC, Mumbai
 * @copyright 2026
 * @Email admin@annlabs.org
 * @Website www.annlabs.org
 ******************************************
 */

:root {
    --primary: #6c5ce7;
    --primary-dark: #5a4bd1;
    --secondary: #a29bfe;
    --success: #00b894;
    --danger: #d63031;
    --warning: #fdcb6e;
    --dark: #2d3436;
    --light: #f5f6fa;
    --gray: #636e72;
    --card-bg: #ffffff;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    line-height: 1.6;
    color: var(--dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Loader */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--secondary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: none; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: none; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Navbar */
.navbar {
    background: var(--dark);
    color: white;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 72px;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
}

.nav-brand a:hover{
    color: var(--primary-dark);
}

.nav-brand img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.nav-links a {
    color: #dfe6e9;
    text-decoration: none;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--secondary);
}

.nav-user {
    color: var(--warning);
    font-weight: 600;
}

.btn-logout {
    background: var(--danger);
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    color: white !important;
}

/* Container */
main.container {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1600px;
    margin: 2rem auto;
    padding: 0 1.2rem;
}

/* Alerts */
.alert {
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    animation: slideIn 0.4s ease;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger);
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
    animation: fadeUp 0.5s ease;
}

.card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--primary);
}

/* Two-column user lists */
.user-list-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
}

.user-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0;
}

.user-list-item a {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-list-item .text-muted {
    flex-shrink: 0;
    font-size: 0.8rem;
}

@media (max-width: 480px) {
    .user-list-grid {
        grid-template-columns: 1fr;
    }
}

/* Forms */
.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid #dfe6e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: #fafbfc;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

select.form-control {
    cursor: pointer;
}

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

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

/* Buttons */
.btn {

    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    margin: 0.25rem; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white !important;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-secondary {
    background: var(--gray);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

/* Auth */
.auth-wrapper {
    max-width: 36rem;
    margin: 3rem auto;
}

.auth-card {
    padding: 2rem;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

/* Confessions tabs */
.tabs, .status-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #dfe6e9;
    margin-bottom: 1.2rem;
}

.tab-btn, .status-tab {
    padding: 0.8rem 1.5rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
}

.tab-btn.active, .status-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn:hover, .status-tab:hover {
    color: var(--primary);
}

.tab-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.filter-select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1.5px solid #dfe6e9;
    font-size: 0.95rem;
    background: white;
}

/* Confession / comment layout */
.confession-card {
    border-left: 4px solid var(--primary);
    position: relative;
}

.confession-header,
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.confession-meta,
.comment-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--gray);
}

.confession-toolbar,
.comment-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
    flex-shrink: 0;
}

.confession-tag {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}

.tag-love          { background: #e84393; }
.tag-breakup       { background: #d63031; }
.tag-crush         { background: #fd79a8; }
.tag-family        { background: #e17055; }
.tag-friends       { background: #00b894; }
.tag-work          { background: #0984e3; }
.tag-school        { background: #6c5ce7; }
.tag-secrets       { background: #2d3436; }
.tag-random        { background: #636e72; }
.tag-relationships { background: #e84393; }
.tag-lonely        { background: #74b9ff; }
.tag-mental        { background: #a29bfe; }
.tag-life          { background: #00cec9; }
.tag-future        { background: #fdcb6e; color: #2d3436; }
.tag-social        { background: #55efc4; color: #2d3436; }
.tag-other         { background: #b2bec3; color: #2d3436; }

.confession-text {
    font-size: 1.05rem;
    margin: 0.5rem 0 0.5rem 1.5rem;
    line-height: 1.7;
    word-wrap: break-word;
    text-align:justify;
}

.emotion-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.65rem 0;
    margin: 0.75rem 0;
    border-top: 1px solid #e5e7eb;
}

.emotion-btn {
    background: #f1f2f6;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.emotion-btn:hover {
    background: #dfe6e9;
}

.emotion-btn.active-like {
    background: #74b9ff;
    color: white;
}

.emotion-btn.active-love {
    background: #fd79a8;
    color: white;
}

.emotion-btn.active-dislike {
    background: #636e72;
    color: white;
}

.emotion-btn .count {
    font-weight: 700;
}

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-approved {
    background: #d4edda;
    color: #155724;
}

.status-disabled {
    background: #f8d7da;
    color: #721c24;
}

.status-review {
    background: #cce5ff;
    color: #004085;
}

/* Comments */
.comment-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin: 0.5rem 0 0.75rem;
}

.comment-form textarea {
    flex: 1;
    min-height: 2.4rem;
    resize: vertical;
}

.comments-section {
    margin-top: 0.25rem;
}

.comment-item {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    margin: 0.5rem 0 0.5rem 1.5rem;
    font-size: 0.95rem;
    border-left: 3px solid var(--primary);
}

.comment-body {
    margin-top: 0.35rem;
    margin-left: 1.5rem;
}

.btn-load-comments {
    margin-top: 0.5rem;
    width: 100%;
}

/* Profile */
.profile-header {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    background: #eee;
}

.avatar-sm {
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 6px;
    border: 2px solid #dfe6e9;
}

.avatar-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0.5rem;
}

.avatar-picker label {
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 50%;
    padding: 2px;
    display: block;
    transition: border-color 0.2s;
}

.avatar-picker label:hover,
.avatar-picker label.selected {
    border-color: var(--primary);
}

.avatar-picker input[type="radio"] {
    display: none;
}

.avatar-picker img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.profile-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stat-box {
    background: var(--light);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    text-align: center;
    min-width: 7rem;
    max-width: 12rem;
}

.stat-box .num {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-box .label {
    font-size: 0.8rem;
    color: var(--gray);
}

/* Index / grids */
.hero {
    text-align: center;
    padding: 2.5rem 1rem;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2.2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--gray);
    max-width: 70rem;
    margin: 0 auto 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal {
    background: white;
    border-radius: var(--radius);
    padding: 1.8rem;
    max-width: 32rem;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: var(--light);
    font-weight: 600;
    font-size: 0.9rem;
}

tr:hover {
    background: #fafbfc;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1.5rem;
}

.pagination a,
.pagination span {
    padding: 0.45rem 0.85rem;
    border-radius: 0.4rem;
    text-decoration: none;
    color: var(--dark);
    background: white;
    border: 1px solid #dfe6e9;
}

.pagination a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Footer */
.footer {
    flex-shrink: 0;
    text-align: center;
    padding: 1.5rem;
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: auto;
    border-top: 1px solid #e5e7eb;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Utility */
.text-muted {
    color: var(--gray);
}

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

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

.loading-more {
    text-align: center;
    padding: 1rem;
    color: var(--gray);
}

.online-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    background: var(--success);
    border-radius: 50%;
    margin-right: 0.25rem;
}

/* Trumbowyg / rich content */
.trumbowyg-box,
.trumbowyg-editor {
    min-height: 6rem !important;
}

#editConfessionModal .trumbowyg-editor,
#adminEditModal .trumbowyg-editor {
    min-height: 6.25rem !important;
    max-height: 12.5rem;
    overflow-y: auto;
}

.trumbowyg-editor,
.rich-content {
    color: #334155;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.trumbowyg-editor p,
.rich-content p {
    margin: 0 0 0.75em;
}

.trumbowyg-editor h1,
.trumbowyg-editor h2,
.trumbowyg-editor h3,
.trumbowyg-editor h4,
.rich-content h1,
.rich-content h2,
.rich-content h3,
.rich-content h4 {
    margin: 1em 0 0.5em;
    line-height: 1.3;
    color: #0f172a;
}

.trumbowyg-editor strong,
.rich-content strong,
.trumbowyg-editor b,
.rich-content b {
    font-weight: 700;
}

.trumbowyg-editor em,
.rich-content em,
.trumbowyg-editor i,
.rich-content i {
    font-style: italic;
}

.trumbowyg-editor u,
.rich-content u {
    text-decoration: underline;
}

.trumbowyg-editor del,
.trumbowyg-editor s,
.rich-content del,
.rich-content s {
    text-decoration: line-through;
    opacity: 0.85;
}

.trumbowyg-editor blockquote,
.rich-content blockquote {
    margin: 0.75rem 0rem;
    padding: 0.625rem 1rem;
    border-left: 4px solid #2563eb;
    background: #f1f5f9;
    color: #475569;
}

.trumbowyg-editor ul,
.rich-content ul {
    list-style: disc;
    margin: 0.5em 0 0.75em;
    padding-left: 1.75em;
}

.trumbowyg-editor ol,
.rich-content ol {
    list-style: decimal;
    margin: 0.5em 0 0.75em;
    padding-left: 1.75em;
}

.trumbowyg-editor ul ul,
.rich-content ul ul {
    list-style: circle;
}

.trumbowyg-editor ul ul ul,
.rich-content ul ul ul {
    list-style: square;
}

.trumbowyg-editor ol ol,
.rich-content ol ol {
    list-style: lower-alpha;
}

.trumbowyg-editor li,
.rich-content li {
    margin: 0.25em 0;
}

.trumbowyg-editor li > p,
.rich-content li > p {
    margin: 0.2em 0;
}

.trumbowyg-editor img,
.rich-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 0.625rem 0rem;
    display: inline-block;
    vertical-align: middle;
}

.trumbowyg-editor img[style*="float: left"],
.rich-content img[style*="float: left"] {
    margin: 0 1rem 0.75rem 0;
}

.trumbowyg-editor img[style*="float: right"],
.rich-content img[style*="float: right"] {
    margin: 0 0 0.75rem 1rem;
}

.trumbowyg-editor hr,
.rich-content hr {
    border: 0;
    border-top: 1px solid #cbd5e1;
    margin: 1.25em 0;
}

.trumbowyg-editor code,
.rich-content code {
    font-family: Consolas, Monaco, monospace;
    font-size: 0.9em;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

.trumbowyg-editor pre,
.rich-content pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 0.9em;
    line-height: 1.5;
}

.trumbowyg-editor pre code,
.rich-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.trumbowyg-editor a,
.rich-content a {
    color: #2563eb;
    text-decoration: underline;
    word-break: break-word;
}

.trumbowyg-editor a:hover,
.rich-content a:hover {
    color: #1d4ed8;
}

.trumbowyg-editor::after,
.rich-content::after {
    content: "";
    display: table;
    clear: both;
}

.trumbowyg-editor[contenteditable="true"]:empty::before {
    content: attr(placeholder);
    color: #999;
}

/* ========== Tablet / phone (=768px) ========== */
@media (max-width: 768px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .navbar {
        position: static;
        top: auto;
        flex-direction: column;
        gap: 0.8rem;
        padding: 1rem;
        min-height: 0;
    }

    .nav-brand {
        margin-bottom: 0.5rem;
        text-align: center;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .confession-header,
    .comment-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .confession-toolbar,
    .comment-toolbar {
        width: 100%;
        justify-content: flex-start;
    }

    .comment-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }

    .comment-form textarea {
        width: 100%;
        min-height: 4rem;
        flex: none;
    }

    .comment-form button {
        width: 100%;
    }

    .trumbowyg-box,
    .trumbowyg-editor {
        min-height: 140px !important;
    }

    #editConfessionModal .trumbowyg-editor,
    #adminEditModal .trumbowyg-editor {
        min-height: 140px !important;
        max-height: 260px;
    }
}

/* ========== Small phones ~5" (=480px) ========== */
@media (max-width: 480px) {
    .navbar {
        position: static;
        top: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        padding: 0.9rem 1rem;
        min-height: 0;
    }

    .nav-brand {
        margin-bottom: 0.75rem;
        text-align: center;
    }

    .nav-brand a {
        font-size: 1.15rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.6rem 0.9rem;
    }

    main.container {
        margin: 1rem auto;
        padding: 0 0.75rem;
    }

    .card {
        padding: 1rem;
    }

    .confession-text {
        margin-left: 0.5rem;
        font-size: 1rem;
    }

    .comment-item {
        margin-left: 0.5rem;
        padding: 0.6rem 0.75rem;
    }

    .comment-body {
        margin-left: 0.5rem;
    }

    /* Taller Trumbowyg */
    .trumbowyg-box,
    .trumbowyg-editor {
        min-height: 160px !important;
    }

    #editConfessionModal .trumbowyg-editor,
    #adminEditModal .trumbowyg-editor {
        min-height: 160px !important;
        max-height: 280px;
    }

    /* Comment form: textarea taller, button below */
    .comment-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }

    .comment-form textarea {
        width: 100%;
        min-height: 5rem;
        flex: none;
    }

    .comment-form button {
        width: 100%;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab-btn {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .modal {
        width: 95%;
        padding: 1.2rem;
        max-height: 85vh;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .emotion-bar {
        flex-wrap: wrap;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .auth-wrapper {
        margin: 1.5rem auto;
    }

    .auth-card {
        padding: 1.25rem;
    }
}
