/* ==========================================================================
   築心數位入口 CHUHSIN LINKS - Material Design 3 & Portaly Inspired Design System
   Reference: https://link.shiquan.tw/
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap');

:root {
    /* Material Design 3 & Google Drive Inspired Tokens */
    --md-sys-color-background: #f8f9fa; /* Light grey surface like Google Drive */
    --md-sys-color-surface: #ffffff;
    --md-sys-color-surface-variant: #f1f3f4; /* Container tint */
    --md-sys-color-primary: #cf3a70; /* Chuhsin Rose Accent */
    --md-sys-color-primary-container: #fce8f0;
    --md-sys-color-on-primary-container: #9b1847;

    --md-sys-color-secondary: #d97706; /* Delango Amber/Gold */
    --md-sys-color-secondary-container: #feefe3;
    --md-sys-color-on-secondary-container: #b06000;

    --md-sys-color-tertiary: #1a73e8; /* Google Blue / Tools */
    --md-sys-color-tertiary-container: #e8f0fe;
    --md-sys-color-on-tertiary-container: #174ea6;

    --md-sys-color-error: #d93025;
    --md-sys-color-outline: #dadce0;
    --md-sys-color-on-surface: #202124;
    --md-sys-color-on-surface-variant: #5f6368;
    
    /* Elevation / Shadows */
    --md-elevation-1: 0px 1px 2px rgba(60,64,67,0.3), 0px 1px 3px 1px rgba(60,64,67,0.15);
    --md-elevation-2: 0px 1px 2px rgba(60,64,67,0.3), 0px 2px 6px 2px rgba(60,64,67,0.15);
    
    /* Typography */
    --font-family: 'Roboto', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Dark Mode Tokens */
@media (prefers-color-scheme: dark) {
    :root {
        --md-sys-color-background: #121212;
        --md-sys-color-surface: #1e1e1e;
        --md-sys-color-surface-variant: #28292a;
        --md-sys-color-outline: #3c4043;
        --md-sys-color-on-surface: #e8eaed;
        --md-sys-color-on-surface-variant: #9aa0a6;

        --md-sys-color-primary-container: #3d1b29;
        --md-sys-color-on-primary-container: #ffb1c8;

        --md-sys-color-secondary-container: #382410;
        --md-sys-color-on-secondary-container: #ffddb3;

        --md-sys-color-tertiary-container: #172b4d;
        --md-sys-color-on-tertiary-container: #aecbfa;

        --md-elevation-1: 0px 1px 3px rgba(0,0,0,0.6), 0px 1px 2px rgba(0,0,0,0.4);
        --md-elevation-2: 0px 2px 6px rgba(0,0,0,0.7), 0px 1px 2px rgba(0,0,0,0.5);
    }
}

[data-theme="dark"] {
    --md-sys-color-background: #121212;
    --md-sys-color-surface: #1e1e1e;
    --md-sys-color-surface-variant: #28292a;
    --md-sys-color-outline: #3c4043;
    --md-sys-color-on-surface: #e8eaed;
    --md-sys-color-on-surface-variant: #9aa0a6;

    --md-sys-color-primary-container: #3d1b29;
    --md-sys-color-on-primary-container: #ffb1c8;

    --md-sys-color-secondary-container: #382410;
    --md-sys-color-on-secondary-container: #ffddb3;

    --md-sys-color-tertiary-container: #172b4d;
    --md-sys-color-on-tertiary-container: #aecbfa;

    --md-elevation-1: 0px 1px 3px rgba(0,0,0,0.6), 0px 1px 2px rgba(0,0,0,0.4);
    --md-elevation-2: 0px 2px 6px rgba(0,0,0,0.7), 0px 1px 2px rgba(0,0,0,0.5);
}

/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    border: none;
    background: none;
}

/* Layout Architecture using CSS Flexbox Layout */
.page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 40px 16px 60px 16px;
}

.main-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 580px;
    background-color: var(--md-sys-color-surface);
    border-radius: 24px; /* Rounded corners typical of MD3 */
    padding: 32px 24px;
    box-shadow: var(--md-elevation-1);
    border: 1px solid var(--md-sys-color-outline);
}

/* Profile Header Area */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 24px;
}

.profile-logo {
    width: 105px;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: 16px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));
    transition: transform 0.25s ease;
}

.profile-logo:hover {
    transform: scale(1.04);
}

.profile-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--md-sys-color-on-surface);
    letter-spacing: -0.5px;
}

.profile-subtitle {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    margin: 0;
    line-height: 1.6;
}

/* ==========================================================================
   Segmented Tabs Navigation (Material Design 3 Style)
   ========================================================================== */
.tabs-container {
    margin-bottom: 24px;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    background-color: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 9999px;
    padding: 4px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 9999px;
    padding: 8px 6px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    user-select: none;
    white-space: nowrap;
}

.tab-btn:hover:not([aria-selected="true"]) {
    color: var(--md-sys-color-on-surface);
    background-color: rgba(255, 255, 255, 0.5);
}

/* Active Segmented Pill */
.tab-btn[aria-selected="true"] {
    background-color: var(--md-sys-color-surface);
    font-weight: 700;
    box-shadow: var(--md-elevation-1);
}

#tab-chuhsin[aria-selected="true"] {
    color: var(--md-sys-color-primary);
}

#tab-delango[aria-selected="true"] {
    color: var(--md-sys-color-secondary);
}

#tab-tools[aria-selected="true"] {
    color: var(--md-sys-color-tertiary);
}



.tab-count {
    font-size: 11.5px;
    opacity: 0.75;
    font-weight: 500;
}

.tab-btn[aria-selected="true"] .tab-count {
    opacity: 1;
    font-weight: 700;
}

/* Tab Panels & Category Sections */
.category-section[role="tabpanel"] {
    display: flex;
    flex-direction: column;
    animation: fadeInTab 0.22s ease-out;
}

.category-section[hidden] {
    display: none !important;
}

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

/* Material Design 3 Typography Header with Left Accent Badge */
.category-title {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--md-sys-color-on-surface-variant);
    margin: 0 0 12px 0;
    padding-left: 8px;
    border-left: 4px solid var(--md-sys-color-primary);
}

/* Category Accent Border Colors */
.section-chuhsin .category-title {
    border-left-color: #cf3a70; /* Chuhsin Rose */
}

.section-delango .category-title {
    border-left-color: #d97706; /* Delango Gold */
}

.section-tools .category-title {
    border-left-color: #1a73e8; /* Google Blue */
}

/* Flexbox Links Grouping */
.links-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Google Style Soft Micro-interaction Buttons */
.link-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 14px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    border: 1px solid transparent;
}

/* Default Hover Interaction */
.link-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.link-item:active {
    transform: translateY(0);
}

/* Category Specific Hover Colors */
.section-chuhsin .link-item:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: rgba(207, 58, 112, 0.2);
}

.section-delango .link-item:hover {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-color: rgba(217, 119, 6, 0.2);
}

.section-tools .link-item:hover {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    border-color: rgba(26, 115, 232, 0.2);
}

/* Favicon Container (Border-free and Transparent) */
.link-label-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.link-favicon-box {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.link-favicon {
    width: 34px;
    height: 34px;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

.link-item:hover .link-favicon {
    transform: scale(1.08);
}

.link-text-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.link-title {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
}

.link-desc {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-item:hover .link-desc {
    color: inherit;
    opacity: 0.85;
}

/* Arrow indicator */
.link-arrow {
    font-size: 14px;
    opacity: 0.5;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

.link-item:hover .link-arrow {
    opacity: 1;
    transform: translateX(3px);
}

/* Security Note Alert inside Tools section */
.security-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    background-color: var(--md-sys-color-background);
    border: 1px dashed var(--md-sys-color-outline);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--md-sys-color-on-surface-variant);
}

.note-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Footer Accent */
.footer-branding {
    margin-top: 32px;
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
    letter-spacing: 0.5px;
    line-height: 1.6;
}

/* Mobile Responsiveness */
@media (max-width: 520px) {
    .page-container {
        padding: 24px 12px 48px 12px;
    }

    .main-card {
        padding: 24px 16px;
        border-radius: 20px;
    }

    .profile-header {
        margin-bottom: 20px;
    }

    .profile-logo {
        width: 90px;
    }

    .profile-title {
        font-size: 20px;
    }

    .profile-subtitle {
        font-size: 13px;
    }

    .tabs-container {
        margin-bottom: 20px;
    }

    .tabs {
        padding: 3px;
        gap: 2px;
    }

    .tab-btn {
        padding: 7px 4px;
        font-size: 12px;
        gap: 3px;
    }



    .tab-count {
        font-size: 10.5px;
    }

    .link-item {
        padding: 11px 13px;
        border-radius: 12px;
    }

    .link-favicon-box {
        width: 28px;
        height: 28px;
    }

    .link-favicon {
        width: 28px;
        height: 28px;
    }

    .link-title {
        font-size: 14.5px;
    }

    .link-desc {
        font-size: 11.5px;
    }
}

/* ==========================================================================
   Internal Tools Lock & Authentication Modal (MD3 Styled)
   ========================================================================== */

/* Tab Lock Icon */
.tab-lock {
    font-size: 11px;
    margin-right: 2px;
    opacity: 0.85;
    transition: transform 0.2s ease;
}

.tab-btn:hover .tab-lock {
    transform: scale(1.15);
}

/* Category Header Row with Relock Option */
.category-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.category-header-row .category-title {
    margin-bottom: 12px;
}

.relock-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    background-color: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 9999px;
    padding: 3px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}

.relock-btn:hover {
    background-color: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Auth Modal Overlay */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(32, 33, 36, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    animation: authFadeIn 0.2s ease-out;
}

.auth-modal-overlay[hidden] {
    display: none !important;
}

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

.auth-modal-card {
    width: 100%;
    max-width: 370px;
    background-color: var(--md-sys-color-surface);
    border-radius: 24px;
    padding: 28px 24px 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
    border: 1px solid var(--md-sys-color-outline);
    position: relative;
    text-align: center;
    animation: authCardScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardScale {
    from { transform: scale(0.92) translateY(12px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.auth-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.auth-close-btn:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}

.auth-icon-wrap {
    font-size: 34px;
    margin-bottom: 10px;
    line-height: 1;
}

.auth-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.5;
    margin-bottom: 20px;
}

.auth-form {
    display: flex;
    flex-direction: column;
}

.auth-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input {
    width: 100%;
    padding: 12px 42px 12px 14px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    background-color: var(--md-sys-color-surface-variant);
    border: 1.5px solid var(--md-sys-color-outline);
    border-radius: 14px;
    color: var(--md-sys-color-on-surface);
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    letter-spacing: 3px;
}

.auth-input:focus {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface);
    box-shadow: 0 0 0 3px rgba(207, 58, 112, 0.15);
}

.auth-input.is-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
    animation: inputShake 0.35s ease;
}

@keyframes inputShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.toggle-pwd-btn {
    position: absolute;
    right: 10px;
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.toggle-pwd-btn:hover {
    opacity: 1;
}

.auth-error-msg {
    font-size: 12.5px;
    color: #dc2626;
    margin-top: 8px;
    font-weight: 500;
}

.auth-error-msg[hidden] {
    display: none;
}

.auth-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.auth-btn {
    flex: 1;
    padding: 11px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-btn-cancel {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline);
}

.auth-btn-cancel:hover {
    background-color: #e5e7eb;
}

.auth-btn-submit {
    background-color: var(--md-sys-color-primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 2px 6px rgba(207, 58, 112, 0.25);
}

.auth-btn-submit:hover {
    background-color: #b82e61;
    box-shadow: 0 4px 10px rgba(207, 58, 112, 0.35);
}

