/* ============================================================
   COTD-WEB — style.css
   ============================================================ */

/* ------------------------------------------------------------
   1. Fonts
   ------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ------------------------------------------------------------
   2. Variables
   ------------------------------------------------------------ */
:root {
    /* Colors */
    --bg:             #0c0e14;
    --bg-surface:     #13151e;
    --bg-raised:      #1c1f2e;
    --bg-hover:       #222538;
    --border:         #252838;
    --border-bright:  #353a55;
    --accent:         #6c8ef5;
    --accent-hover:   #8aa4ff;
    --accent-dim:     rgba(108, 142, 245, 0.1);
    --accent-glow:    rgba(108, 142, 245, 0.2);
    --text:           #e8ecf8;
    --text-muted:     #6b7299;
    --text-faint:     #363a52;
    --success:        #4ade9a;
    --success-dim:    rgba(74, 222, 154, 0.12);
    --error:          #f26b6b;
    --error-dim:      rgba(242, 107, 107, 0.12);
    --warning:        #f0b86b;
    --warning-dim:    rgba(240, 184, 107, 0.12);

    /* Typography */
    --font-sans:      'Outfit', sans-serif;
    --font-mono:      'JetBrains Mono', monospace;

    /* Shape */
    --radius-sm:      4px;
    --radius:         8px;
    --radius-lg:      12px;
    --radius-xl:      16px;

    /* Shadows */
    --shadow:         0 2px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg:      0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-accent:  0 4px 24px rgba(108, 142, 245, 0.15);
}

/* ------------------------------------------------------------
   3. Reset
   ------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ------------------------------------------------------------
   4. Base
   ------------------------------------------------------------ */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ------------------------------------------------------------
   5. Nav
   ------------------------------------------------------------ */
nav {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.status-indicator {
    font-size: 20px;
    color: var(--text-faint);
    transition: color 0.4s, filter 0.4s;
    cursor: default;
    line-height: 1;
    flex-shrink: 0;
    align-self: center;
    position: relative;
    top: -4px;
}

.status-indicator.status-ok {
    color: var(--success);
    filter: drop-shadow(0 0 6px rgba(74, 222, 154, 0.5));
}

.status-indicator.status-error {
    color: var(--error);
    filter: drop-shadow(0 0 6px rgba(242, 107, 107, 0.5));
}

.nav-brand {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 2px;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--radius);
    transition: color 0.2s, background 0.2s;
    letter-spacing: 0.01em;
}

.nav-links a:hover {
    color: var(--text);
    background: var(--accent-dim);
    text-decoration: none;
}

.nav-links a.nav-active {
    color: var(--accent);
    background: var(--accent-dim);
}

.nav-user-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-bright);
}

/* Mobile right side */
.nav-mobile-right {
    display: none;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.nav-avatar-collapsed {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-bright);
}

/* Hamburger */
.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    box-shadow: none;
    transform: none;
}

.nav-toggle:hover {
    background: none;
    box-shadow: none;
    transform: none;
}

.toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease, background 0.2s;
    transform-origin: center;
}

.nav-toggle:hover .toggle-bar {
    background: var(--text);
}

.nav-toggle-open .toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle-open .toggle-bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-toggle-open .toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ------------------------------------------------------------
   6. Page Content
   ------------------------------------------------------------ */
.content {
    flex: 1;
    padding: 40px 32px;
    max-width: 1040px;
    width: 100%;
    margin: 0 auto;
}

h1 {
    font-family: var(--font-sans);
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

h2 {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    margin-bottom: 14px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

p {
    color: var(--text-muted);
    margin-bottom: 12px;
    font-size: 15px;
}

/* ------------------------------------------------------------
   7. Cards
   ------------------------------------------------------------ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

/* Hero card */
.hero {
    text-align: center;
    padding: 72px 40px;
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-raised) 100%);
    border: 1px solid var(--border-bright);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-size: 32px;
    margin-bottom: 12px;
    position: relative;
}

.hero p {
    font-size: 16px;
    margin-bottom: 28px;
    position: relative;
}

/* ------------------------------------------------------------
   8. Guild Cards
   ------------------------------------------------------------ */
.guild-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.guild-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.guild-card:hover {
    border-color: var(--border-bright);
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
}

.guild-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.guild-card-link:hover {
    text-decoration: none;
    color: inherit;
}

.guild-card > div:first-child,
.guild-card-link > div {
    display: flex;
    align-items: center;
    gap: 14px;
}

.guild-icon img,
.guild-icon-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.guild-icon-placeholder {
    background: var(--bg-raised);
    border: 1px solid var(--border-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 18px;
    color: var(--text-muted);
}

.guild-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.guild-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    color: var(--text);
}

.guild-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    width: fit-content;
    letter-spacing: 0.03em;
}

.badge-ok      { background: var(--success-dim); color: var(--success); }
.badge-error   { background: var(--error-dim); color: var(--error); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-muted   { background: var(--bg-raised); color: var(--text-muted); border: 1px solid var(--border-bright); }

/* ------------------------------------------------------------
   9. Buttons
   ------------------------------------------------------------ */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

button:hover,
.btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-accent);
    text-decoration: none;
    transform: translateY(-1px);
}

button:active,
.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-raised);
    color: var(--text-muted);
    border: 1px solid var(--border-bright);
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text);
    box-shadow: none;
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid rgba(242, 107, 107, 0.3);
    padding: 5px 12px;
    font-size: 13px;
}

.btn-danger:hover {
    background: var(--error-dim);
    border-color: var(--error);
    box-shadow: none;
    transform: none;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ------------------------------------------------------------
   10. Forms & Inputs
   ------------------------------------------------------------ */
input[type="text"],
input[type="date"],
select {
    padding: 9px 13px;
    font-family: var(--font-sans);
    font-size: 14px;
    background: var(--bg-raised);
    color: var(--text);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 180px;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder {
    color: var(--text-faint);
}

input[type="file"] {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-muted);
}

.filter-form,
.add-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* ------------------------------------------------------------
   11. Tables
   ------------------------------------------------------------ */

/* Info table — key/value pairs */
.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.info-table tr:last-child td {
    border-bottom: none;
}

.info-table td:first-child {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    width: 220px;
}

/* Data table — rows of records */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-bright);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-raised);
}

/* ------------------------------------------------------------
   12. Status Bar
   ------------------------------------------------------------ */
.status-bar {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    margin-bottom: 28px;
    letter-spacing: 0.03em;
}

.status-bar-ok {
    background: var(--success-dim);
    border: 1px solid rgba(74, 222, 154, 0.2);
    color: var(--success);
}

.status-bar-error {
    background: var(--error-dim);
    border: 1px solid rgba(242, 107, 107, 0.2);
    color: var(--error);
}

/* ------------------------------------------------------------
   13. Guild Header
   ------------------------------------------------------------ */
.guild-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}

.guild-header-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border-bright);
}

.guild-header h1 {
    margin-bottom: 4px;
}

/* ------------------------------------------------------------
   14. User Cell
   ------------------------------------------------------------ */
.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-bright);
}

/* ------------------------------------------------------------
   15. Modal
   ------------------------------------------------------------ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-xl);
    padding: 12px;
    box-shadow: var(--shadow-lg);
}

.modal-img {
    display: block;
    max-width: 80vw;
    max-height: 80vh;
    border-radius: var(--radius);
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    background: var(--bg-raised);
    border: 1px solid var(--border-bright);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    box-shadow: none;
    transform: none;
}

.modal-close:hover {
    background: var(--error-dim);
    color: var(--error);
    border-color: var(--error);
    box-shadow: none;
    transform: none;
}

/* ------------------------------------------------------------
   16. Feedback
   ------------------------------------------------------------ */
.success { color: var(--success); }
.error   { color: var(--error); }
.warning { color: var(--warning); }

.result-box {
    background: var(--bg-raised);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 16px;
    color: var(--text);
    line-height: 1.6;
}

/* ------------------------------------------------------------
   17. Utility
   ------------------------------------------------------------ */
.mono       { font-family: var(--font-mono); font-size: 13px; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-8       { margin-top: 8px; }
.mt-16      { margin-top: 16px; }
.mt-24      { margin-top: 24px; }

/* ------------------------------------------------------------
   18. Footer
   ------------------------------------------------------------ */
footer {
    text-align: center;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
    border-top: 1px solid var(--border);
    letter-spacing: 0.05em;
}

/* ------------------------------------------------------------
   19. Mobile
   ------------------------------------------------------------ */
@media (max-width: 640px) {
    nav {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 0;
        row-gap: 0;
        .status-indicator {
            align-self: center;
            margin-top: 0;
        }
    }

    .nav-brand {
        margin-left: 8px;
    }

    .nav-mobile-right {
        display: flex;
    }

    .nav-links {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
        gap: 0;
    }

    .nav-links.nav-open {
        max-height: 200px;
        padding: 8px 0;
        border-top: 1px solid var(--border);
        margin-top: 8px;
        gap: 2px;
    }

    .nav-links a {
        padding: 10px 12px;
        display: block;
        border-radius: var(--radius);
    }

    .nav-user-section {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
        margin-left: 0;
        gap: 0;
    }

    .nav-user-section.nav-open {
        max-height: 120px;
        padding: 8px 0;
        border-top: 1px solid var(--border);
        margin-top: 0;
        gap: 8px;
    }

    .nav-username {
        display: none;
    }

    .nav-user-section.nav-open .nav-username {
        display: inline;
    }

    .content {
        padding: 24px 16px;
    }

    .guild-grid {
        grid-template-columns: 1fr;
    }

    .add-form {
        flex-direction: column;
        align-items: stretch;
    }

    .add-form input,
    .add-form select {
        min-width: unset;
        width: 100%;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .guild-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .hero {
        padding: 48px 24px;
    }

    .hero h1 {
        font-size: 24px;
    }

    h1 {
        font-size: 20px;
    }
}