/* wire_common.css - common styles extracted from page inline styles */

/* Layout */
.page-container {
    padding: 0 1.5rem 2rem;
}

/* Expert list shared components */
.expert-select-wrapper {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.posts-header {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-color-strong);
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

/* Posts list */
.post-list .post-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.post-item .content {
    display: flex;
    align-items: center;
    overflow: hidden;
}

#posts-content .controls {
    text-align: right;
    margin-bottom: 0.5rem;
    height: 0rem;
}

#show-all-posts {
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    visibility: hidden;
    /* Initially hidden */
}

#show-all-posts:hover {
    text-decoration: underline;
}

.post-item .author-tag,
.article-meta .author-link {
    flex-shrink: 0;
    width: 60px;
    padding: 0.3rem 0;
    margin-right: 0;
    border-radius: 6px;
    background-color: #E7F1FA;
    /* Light blue tint */
    color: var(--primary-color);
    font-weight: 600;
    text-align: center;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.post-item .author-tag:hover,
.article-meta .author-link:hover {
    background-color: #D0E3F8;
    text-decoration: none;
}

.post-item .post-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color-default);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-item .post-date {
    flex-shrink: 0;
    margin-left: 0;
}

/* Shared posts list layout (from wire_expert.html) */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.post-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

.post-item .content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    flex: 1;
}

.post-item .title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.post-title {
    display: block;
    font-weight: 600;
    color: var(--text-color-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-color-muted);
    margin-top: 0.25rem;
    width: 100%;
}

.post-views {
    color: var(--text-color-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Profile-specific post actions (edit/delete icons) - Existing styles */
.profile-actions+section .post-list .post-item {
    align-items: center;
    padding-right: 0.5rem;
}

.profile-actions+section .post-list .post-item .content {
    max-width: calc(100% - 30px);
}

.profile-actions+section .post-list .post-item .post-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
    align-items: center;
}

.post-actions .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-color-default);
    text-decoration: none;
}

.post-actions .icon-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    color: inherit;
}

.post-actions .icon-btn.edit:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--primary-color);
}

.post-actions .icon-btn.delete:hover {
    background: rgba(220, 53, 69, 0.08);
    color: #dc3545;
}

/* New Expert Profile Styles (Refactored from inline) */
.expert-write-row {
    display: none;
    /* Controlled by JS */
    justify-content: flex-end;
    margin-bottom: 1rem;
    padding: 0 1rem;
}

.expert-post-actions {
    margin-top: 1rem;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    display: none;
    /* Controlled by JS */
}

.expert-post-actions .btn {
    font-size: 0.9rem;
    padding: 0.4rem 1.2rem;
    min-width: 60px;
}

/* Login form utilities */
.center-viewport {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    /* align to top on mobile */
    justify-content: center;
    /* Restored padding to original value for consistent vertical spacing */
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 1.25rem;
    /* uniform padding */
    margin-top: 20px;
    /* small offset from the top */
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
}

/* Login header: inline back button + title */
.login-card .login-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* balanced gap */
    margin-bottom: 0.5rem;
}

/* Make back button large but snug to its SVG */
.login-card .back-link {
    position: static;
    display: inline-flex;
    align-items: center;
    padding: 0.15rem;
    /* reduced padding for snug fit */
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color-strong);
}

.login-card .back-link svg {
    width: 2.6rem;
    /* desired visual size */
    height: 2.6rem;
    color: var(--text-color-strong);
}

.login-card .back-link:hover {
    background: rgba(0, 0, 0, 0.04);
}

.form-group {
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-size: 0.95rem;
    color: var(--text-color-light);
}

.input {
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-color);
    color: var(--text-color-default);
}

.input-row {
    position: relative;
    display: flex;
    align-items: center;
}

.toggle-password {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0.4rem;
    display: inline-flex;
    align-items: center;
    color: var(--text-color-light);
}

.small {
    font-size: 0.9rem;
    color: var(--text-color-light);
    text-align: right;
    margin-top: 0.5rem;
    padding-bottom: 0.8rem;
}

.small a {
    color: var(--primary-color);
}

.btn-submit {
    margin-top: 0.5rem;
}

/* Consolidated page styles and responsive rules (for 280px support) */
/* ----- Tab Navigation ----- */
.tab-nav {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.tab-button {
    padding: 0.5rem 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-color-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-button.active {
    background-color: var(--primary-color);
    color: var(--surface-color);
    border-color: var(--primary-color);
}

/* ----- Experts Grid ----- */
.expert-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.expert-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    padding-bottom: 2rem;
}

.expert-card img {
    width: 100%;
    max-width: 120px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.expert-card .name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color-strong);
}

/* ----- Expert Profile Card ----- */
.expert-profile-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
}

.expert-profile-card .profile-image {
    flex-shrink: 0;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.expert-profile-card .name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color-strong);
    margin: 0 0 0.25rem;
}

.expert-profile-card .tagline {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--primary-color);
    margin: 0 0 1rem;
}

/* Profile actions (such as 글쓰기) placed between profile and posts */
.profile-actions {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 1rem;
}

.profile-actions .btn {
    width: auto;
    padding: 0.6rem 0.95rem;
    font-size: 1rem;
}

/* ----- Article / Post styles ----- */
.article-header {
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.article-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color-strong);
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.article-meta {
    align-items: center;
    font-size: 1rem;
    color: var(--text-color-light);
}

.article-body {
    font-size: 1.125rem;
    line-height: 0.95;
    color: var(--text-color-default);
    margin-bottom: 2.5rem;
}

.article-body p {
    margin-bottom: 1.5em;
}

/* Ensure media/audio/images scale down on narrow screens */
img,
iframe,
video,
embed {
    max-width: 100%;
    height: auto;
    min-width: 0;
}

audio[controls] {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
}

/* Pdf card moved here */
.pdf-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pdf-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--surface-color);
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.pdf-card .card-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color-strong);
    margin: 0.25rem 0;
}

.pdf-card .card-subtitle {
    font-size: 1rem;
    color: var(--text-color-light);
    margin: 0.5rem 0 0.8rem;
}

.pdf-card .button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}

.pdf-card .download-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem 0.5rem;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: var(--surface-color);
    font-size: 1rem;
    line-height: 1.4;
    transition: background-color 0.2s ease;
}

.pdf-card.pdf-type-1 .download-btn {
    background-color: #dc3545;
    color: #fff;
}

.pdf-card.pdf-type-1 .download-btn:hover {
    background-color: #b92b3b;
}

.pdf-card.pdf-type-2 .download-btn {
    background-color: #fbd84f;
    color: #1a1a1a;
}

/* Main grid (home) */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.card-link.primary {
    background-color: var(--primary-color);
    color: var(--surface-color);
    min-height: 100px;
}

/* Secondary cards: fixed card height, per-card image height via --card-img-height */
.card-link.secondary {
    background-color: var(--surface-color);
    color: var(--text-color-strong);
    padding: 8px;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
    /* ensure contents don't push height */
    /* default fixed height for all secondary cards — change value as needed */
    --card-secondary-height: 100px;
    /* default card height */
    height: var(--card-secondary-height);
}

/* Images inside secondary cards can be set per-card using --card-img-height; they will not change the card height */
.card-link.secondary img {
    width: 80%;
    object-fit: contain;
    display: block;
    margin: 10px 0;
    height: var(--card-img-height, auto);
    max-height: calc(var(--card-secondary-height) - 20px);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.pagination a {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    color: var(--text-color-default);
    margin: 0 2px;
    border-radius: 6px;
}

.pagination a:hover {
    background-color: var(--background-color);
    text-decoration: none;
}

.pagination a[aria-current='page'] {
    background-color: var(--primary-color);
    color: var(--surface-color);
    border-color: var(--primary-color);
    font-weight: 600;
}

/* Footer */
.main-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-top: 2rem;
    /* spacing from main content */
    padding: 1.25rem 0;
}

/* Ensure the first primary card (전문가 게시판) has a small top offset */
.main-grid>.card-link.primary:first-child {
    margin-top: 0.8rem;
}

/* Custom Button Styles for Expert Board and PDF Download */
.card-link.btn-expert,
.card-link.btn-pdf {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    /* Overriding default card-link padding if necessary to control exact 10% margin from edge */
    padding: 1.2rem 0;
}

.card-link.btn-expert {
    background-color: #fef0c9;
    border: 1px solid #f26a03;
    color: #830001;
}

.card-link.btn-pdf {
    background-color: #edf4fd;
    border: 1px solid #387ecc;
    color: #124298;
}

.card-link.btn-expert img,
.card-link.btn-pdf img {
    margin-left: 10%;
    margin-right: 15px;
    flex-shrink: 0;
    height: 50px;
    /* Prevent image from shrinking */
}

@media (min-width: 421px) {

    .card-link.btn-expert,
    .card-link.btn-pdf {
        justify-content: center;
    }

    .card-link.btn-expert img,
    .card-link.btn-pdf img {
        margin-left: 0;
    }
}

/* =========================================
   Media Queries (Consolidated)
   ========================================= */

@media (max-width: 420px) {

    /* Login & Profile */
    .login-card {
        padding: 0 1rem !important;
        margin-top: 12px !important;
    }

    .login-card .back-link {
        padding: 0.08rem;
    }

    .login-card .back-link svg {
        width: 1.6rem;
        height: 1.6rem;
    }

    .login-card .login-header {
        gap: 0.45rem;
    }

    .profile-actions {
        justify-content: center;
    }

    .profile-actions .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.95rem;
    }

    /* Grids & Layouts */
    .expert-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .tab-button {
        font-size: 1rem;
    }

    .card-link {
        font-size: 1.3rem;
        padding: 1rem;
    }

    .pdf-card {
        padding: 0.9rem;
    }
}

@media (max-width: 360px) and (min-width: 281px) {

    /* Login refinements */
    .login-card {
        padding: 0 1rem !important;
    }

    .login-card .login-header {
        gap: 0.4rem;
    }

    .login-card .login-header h1,
    .login-card h1 {
        flex: 1;
        min-width: 0;
        font-size: 1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .login-card .back-link {
        padding: 0.05rem;
    }

    .login-card .back-link svg {
        width: 1.6rem;
        height: 1.6rem;
    }
}

@media (max-width: 320px) {

    /* Container & Layout */
    .page-container {
        padding: 0 0.75rem 1.25rem !important;
    }

    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        box-sizing: border-box !important;
    }

    /* Typography & Sizes */
    .page-header .page-title {
        font-size: 1.125rem !important;
    }

    .tab-button {
        font-size: 0.98rem !important;
        padding: 0.45rem 0.6rem !important;
    }

    .article-title {
        font-size: 1.25rem !important;
    }

    .article-body {
        font-size: 16px !important;
        line-height: 1.6 !important;
    }

    .expert-profile-card .name {
        font-size: 1.25rem !important;
    }

    /* Components */
    .expert-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .expert-card img {
        max-width: 92px !important;
    }

    .expert-profile-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 1rem 0.75rem !important;
        gap: 0.75rem !important;
    }

    .expert-profile-card .profile-image {
        width: 72px !important;
        height: 72px !important;
        align-self: center !important;
    }

    .card-link.secondary {
        --card-secondary-height: 80px !important;
    }

    .pdf-card .download-btn {
        padding: 0.6rem 0.5rem !important;
        font-size: 0.9rem !important;
    }

    .pagination a {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.9rem !important;
    }

    audio[controls] {
        min-height: 36px !important;
    }

    /* Font scaling adjustments */
    .article-body [style*="font-size"],
    .article-body [style*="FONT-SIZE"] {
        font-size: clamp(12px, 4vw, 20px) !important;
    }
}

@media (max-width: 280px) {

    /* Extreme small screens */
    .page-header .page-title {
        font-size: 1rem !important;
    }

    .tab-button {
        font-size: 0.9rem !important;
        padding: 0.4rem 0.5rem !important;
    }

    .expert-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.4rem !important;
    }

    .expert-card img {
        max-width: 72px !important;
    }

    .expert-profile-card .profile-image {
        width: 64px !important;
        height: 64px !important;
    }

    .article-title {
        font-size: 1.1rem !important;
    }

    .article-body {
        font-size: 15px !important;
    }

    .pdf-card .download-btn {
        font-size: 0.85rem !important;
        padding: 0.5rem !important;
    }

    .card-link.primary {
        min-height: 88px !important;
    }

    .card-link.secondary img {
        width: 70% !important;
    }

    /* Login & Inputs */
    .login-card {
        padding: 0 1rem !important;
        margin-top: 12px !important;
    }

    .login-card h1 {
        font-size: 1.125rem !important;
    }

    .input {
        padding: 0.6rem !important;
    }

    .btn {
        padding: 0.7rem 0.9rem !important;
    }

    /* Profile actions layout tweak */
    .profile-actions+section .post-list .post-item {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-actions+section .post-list .post-item .post-actions {
        flex-direction: row;
        justify-content: flex-end;
        order: -1;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .profile-actions+section .post-list .post-item .content {
        max-width: 100%;
    }

    .post-actions .icon-btn {
        width: 32px;
        height: 32px;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    width: calc(100% - 48px);
    text-align: center;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.modal-message {
    margin-bottom: 1.5rem;
    font-size: 1rem;
    color: var(--text-color-default);
    line-height: 1.5;
}