/* ============================================================
   common.css — shared styles across all app pages
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@400;500;600&display=swap');

/* Green palette (matches home page) */
:root {
    --green-dark:    #1A2E25;
    --green-primary: #2D4A3E;
    --green-mid:     #1E6644;
    --green-text:    #3D5E4E;
    --green-muted:   #4A6B5A;
    --green-subtle:  #5A7A6A;
    --green-border:  #C8DFD2;
    --green-light:   #EEF7F1;
    --green-pale:    #F5FAF7;
    --green-hover:   #D4EFE2;
    --accent-warm:   #F4A261;
    --accent-cream:  #FEF3E2;
    --accent-gold:   #E9C46A;
    --text-cta:      #E8F5EF;
}

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

/* Base body */
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
}

/* Gradient background */
body.gradient-bg {
    background: linear-gradient(160deg, var(--green-dark) 0%, var(--green-primary) 55%, var(--green-mid) 100%);
}

/* ---- App header / nav bar ---- */
.header {
    background: white;
    padding: 15px 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-left: auto;
    margin-right: auto;
}

.nav-brand {
    font-family: 'Fraunces', serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--green-primary);
    text-align: center;
}

.nav-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}

.nav-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-brand-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-brand-home {
    font-family: 'Fraunces', serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--green-primary);
    text-decoration: none;
}

.nav-button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
    margin-top: 0;
}

.nav-button.primary {
    background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-mid) 100%);
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-button.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 102, 68, 0.35);
}

/* ---- User avatar dropdown ---- */
.nav-user-menu {
    position: relative;
}

.nav-avatar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--green-pale);
    border: 1px solid var(--green-border);
    border-radius: 20px;
    padding: 5px 12px 5px 5px;
    cursor: pointer;
    width: auto;
    margin-top: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--green-primary);
    transition: background 0.2s;
}

.nav-avatar-btn:hover {
    background: var(--green-hover);
    transform: none;
    box-shadow: none;
}

.nav-avatar-initial {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-mid) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-avatar-caret {
    font-size: 10px;
    color: var(--green-muted);
}

.nav-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: white;
    border: 1px solid var(--green-border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(45, 74, 62, 0.12);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.nav-dropdown.open {
    display: block;
}

.nav-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    font-size: 14px;
    color: var(--green-text);
    cursor: pointer;
    text-decoration: none;
    margin: 0;
    transition: background 0.15s;
}

.nav-dropdown-item:hover {
    background: var(--green-pale);
    transform: none;
    box-shadow: none;
}

.nav-dropdown-divider {
    height: 1px;
    background: var(--green-border);
    margin: 4px 0;
}

.nav-dropdown-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--green-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px 16px 4px;
    margin-top: 2px;
}

/* ---- White content card ---- */
.container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
    margin: 0 auto;
}

h1 {
    color: var(--green-dark);
    margin-bottom: 30px;
    text-align: center;
    font-size: 28px;
    font-family: 'Fraunces', serif;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--green-text);
    font-weight: 500;
    font-size: 14px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--green-border);
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--green-mid);
    box-shadow: 0 0 0 3px rgba(30, 102, 68, 0.1);
}

button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-mid) 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(30, 102, 68, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---- Error & loading states ---- */
.error {
    padding: 12px;
    margin-bottom: 20px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 5px;
    color: #c33;
    display: none;
    font-size: 14px;
}

.error.visible {
    display: block;
}

.loading {
    text-align: center;
    color: var(--green-mid);
    font-weight: 600;
}

/* ---- OAuth / divider ---- */
.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px;
    border: 2px solid var(--green-border);
    border-radius: 5px;
    background: white;
    color: var(--green-text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-top: 0;
}

.oauth-btn:hover {
    border-color: var(--green-muted);
    box-shadow: 0 2px 8px rgba(45, 74, 62, 0.1);
    transform: none;
}

.oauth-btn svg {
    flex-shrink: 0;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    color: #bbb;
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--green-border);
}

/* ---- Modal ---- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.visible {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
    color: var(--green-dark);
    font-size: 20px;
    font-family: 'Fraunces', serif;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: auto;
    margin-top: 0;
    line-height: 1;
    flex-shrink: 0;
}

.close-btn:hover {
    color: var(--green-dark);
    transform: none;
    box-shadow: none;
}

.modal-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 20px;
}

.modal-story {
    color: var(--green-text);
    line-height: 1.8;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.modal-rating {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--green-border);
}

.rating-btn {
    background: var(--green-pale);
    border: 2px solid var(--green-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 18px;
    line-height: 1;
    width: auto;
    margin-top: 0;
}

.rating-btn.selected {
    background: var(--green-light);
    border-color: var(--green-mid);
}

/* ---- Membership badge ---- */
.membership-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    align-self: flex-start;
    width: fit-content;
}

.membership-badge.free {
    background: var(--green-pale);
    color: var(--green-muted);
}

.membership-badge.pro {
    background: linear-gradient(135deg, #43b89c 0%, #2e8f6e 100%);
    color: white;
}

.membership-badge.family {
    background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-dark) 100%);
    color: white;
}

.membership-badge.enterprise {
    background: linear-gradient(135deg, var(--accent-warm) 0%, #7c5cbf 100%);
    color: white;
}

.membership-badge.rockstar {
    background: linear-gradient(135deg, var(--accent-warm) 0%, var(--green-mid) 100%);
    color: white;
}

.stories-remaining {
    font-size: 12px;
    color: var(--green-muted);
}

.stories-remaining.limit-near {
    color: #e67e22;
    font-weight: 600;
}

.stories-remaining.limit-reached {
    color: #c33;
    font-weight: 600;
}

.user-info {
    font-size: 13px;
    color: var(--green-muted);
}

/* ---- Active nav item ---- */
.nav-dropdown-item--active {
    background: var(--green-light);
    color: var(--green-mid);
    font-weight: 700;
}

/* ---- App switcher bar ---- */
.app-switcher {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: -8px auto 16px;
    max-width: 100%;
    padding: 0 16px;
}

.app-switcher-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border-radius: 20px;
    background: rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1.5px solid rgba(255,255,255,0.28);
    transition: background 0.18s, border-color 0.18s;
    white-space: nowrap;
}

.app-switcher-tab:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

.app-switcher-tab--active {
    background: white;
    color: var(--green-primary);
    border-color: white;
}

.app-switcher-tab--active:hover {
    background: white;
}

/* ---- Mobile nav ---- */
@media (max-width: 600px) {
    .header {
        grid-template-columns: 1fr auto;
        padding: 12px 16px;
    }

    .nav-brand {
        display: none;
    }

    .nav-button.primary {
        display: none;
    }

    .stories-remaining {
        display: none;
    }
}


/* ---- Feature flag visual indicators (admin mode) ---- */
.feature-preview::after {
    content: 'Preview';
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: rgba(66,160,247,.2);
    color: #4ab0f7;
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
}

.feature-in-dev::after {
    content: 'Dev';
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: rgba(255,160,50,.15);
    color: #f0a030;
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
}
