/* pibiCo Brand Stylesheet — api_script */

:root {
    /* Brand colors — Scriptorium dark parchment + gold */
    --primary-color:    #C9A043;
    --secondary-color:  #E8E0CC;
    --accent-color:     #8B2020;
    --text-color:       #1C1812;
    --text-light:       #5C4A2A;
    --bg-gradient:      linear-gradient(135deg, #1C1812 0%, #2E2416 50%, #1A1610 100%);
    --glass-bg:         rgba(245, 240, 230, 0.92);
    --glass-border:     rgba(201, 160, 67, 0.25);

    /* Scriptorium palette */
    --parchment:   #F5F0E6;
    --vitela:      #E8E0CC;
    --gold:        #C9A043;
    --gold-dark:   #A67C2E;
    --crimson:     #8B2020;
    --lapis:       #2C4A7C;
    --ink:         #1C1812;

    /* Semantic */
    --danger:   #e53e3e;
    --success:  #10b981;
    --warning:  #fbbf24;

    /* Borders / shadow */
    --border:   rgba(201, 160, 67, 0.22);
    --shadow:   0 4px 16px rgba(0, 0, 0, 0.35);

    /* Layout heights */
    --navbar-h: 48px;
    --footer-h: 42px;

    /* Typography */
    --font-brand:   'Raleway',       'Montserrat', 'Arial', sans-serif;
    --font-heading: 'Raleway',       'Montserrat', 'Arial', sans-serif;
    --font-body:    'Inter',         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:    'JetBrains Mono','Fira Code', 'Cascadia Code', 'Consolas', monospace;

    /* Backwards-compat aliases (used by script.css) */
    --text:       var(--text-color);
    --text-muted: var(--text-light);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.2;
    overflow-x: hidden;
}

/* ── App Layout — full-height flex column ── */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ── */
.app-header {
    background: rgba(28, 24, 18, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(201, 160, 67, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    padding: 0 1.5rem;
    height: var(--navbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 100;
    color: rgba(245, 240, 230, 0.85);
}

.app-header-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.125rem;
    color: #C9A043;
    text-decoration: none;
}

.app-header-title img {
    height: 24px;
    width: 24px;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-header-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    color: rgba(245, 240, 230, 0.75);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1.2;
}

.app-header-link:hover {
    background: rgba(201, 160, 67, 0.15);
    color: #C9A043;
}

/* Icon-only header buttons (36×36) */
.app-header-btn {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: rgba(245, 240, 230, 0.75);
    flex-shrink: 0;
}

.app-header-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-header-btn:hover {
    background: rgba(201, 160, 67, 0.15);
    color: #C9A043;
}

/* ── Main Content ── */
.app-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Footer ── */
.app-footer {
    background: rgba(28, 24, 18, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(201, 160, 67, 0.3);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.35);
    padding: 0 1.5rem;
    height: var(--footer-h);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: rgba(245, 240, 230, 0.6);
    flex-shrink: 0;
}

.app-footer a {
    color: #C9A043;
    text-decoration: none;
}

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

.footer-sep {
    color: rgba(201, 160, 67, 0.4);
}

/* ── Cards ── */
.pibico-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ── Inputs ── */
.pibico-input {
    width: 100%;
    padding: 5px 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: var(--font-body);
    background: white;
    color: var(--text-color);
    transition: all 0.2s;
    line-height: 1.4;
}

.pibico-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(201, 160, 67, 0.15);
}

.pibico-input:disabled {
    background: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

/* ── Form labels ── */
.form-group {
    margin-bottom: 12px;
}

.form-group label,
.pibico-label {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 3px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.flex-1 { flex: 1; }

.form-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 14px 0 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    font-family: var(--font-heading);
}

.cb-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-light);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

/* ── Buttons ── */
.pibico-btn {
    padding: 5px 14px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.2;
    text-decoration: none;
    flex-shrink: 0;
}

.pibico-btn-primary {
    background: #C9A043;
    color: #1C1812;
}

.pibico-btn-primary:hover:not(:disabled) {
    background: #A67C2E;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(201, 160, 67, 0.4);
}

.pibico-btn-outline {
    background: transparent;
    color: #8B2020;
    box-shadow: inset 0 0 0 1.5px #C9A043;
}

.pibico-btn-outline:hover:not(:disabled) {
    background: rgba(201, 160, 67, 0.1);
}

.pibico-btn-ghost {
    background: transparent;
    color: var(--text-light);
}

.pibico-btn-ghost:hover:not(:disabled) {
    background: rgba(201, 160, 67, 0.1);
    color: var(--text-color);
}

.pibico-btn-danger {
    background: transparent;
    color: var(--danger);
    box-shadow: inset 0 0 0 1.5px var(--danger);
}

.pibico-btn-danger:hover:not(:disabled) {
    background: rgba(229, 62, 62, 0.08);
}

.pibico-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pibico-btn-sm {
    padding: 3px 10px;
    font-size: 0.8rem;
}

.pibico-btn-xs {
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 5px;
}

/* ── Icon buttons ── */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--text-light);
    font-size: 13px;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}

.btn-icon:hover { background: rgba(201, 160, 67, 0.15); color: var(--primary-color); }
.btn-icon.danger:hover { background: rgba(229, 62, 62, 0.1); color: var(--danger); }

/* ── Slide Panels ── */
.slide-panel {
    position: fixed;
    top: 0;
    right: -50%;
    width: 45%;
    min-width: 320px;
    height: 100vh;
    z-index: 200;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.slide-panel.open { right: 0; }

.panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(28, 24, 18, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.panel-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--accent-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 6px;
    font-size: 16px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.panel-close:hover { color: var(--danger); background: rgba(229, 62, 62, 0.1); }

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.panel-actions {
    display: flex;
    gap: 8px;
    padding-top: 14px;
}

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-family: var(--font-body);
    line-height: 1.4;
}

.badge-cdti      { background: #ebf8ff; color: #2b6cb0; }
.badge-ccaa      { background: #f0fff4; color: #276749; }
.badge-h2020     { background: #faf5ff; color: #6b46c1; }
.badge-other     { background: #fffaf0; color: #975a16; }
.badge-draft     { background: #f7fafc; color: #718096; }
.badge-submitted { background: #ebf8ff; color: #2b6cb0; }
.badge-approved  { background: #f0fff4; color: #276749; }
.badge-rejected  { background: #fff5f5; color: #c53030; }
.badge-granted   { background: #f0fff4; color: #276749; }
.badge-denied    { background: #fff5f5; color: #c53030; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 56px;
    right: 20px;
    z-index: 300;
    padding: 10px 18px;
    border-radius: 8px;
    background: #1a202c;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    max-width: 320px;
}

.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.error   { background: var(--danger); }
.toast.success { background: var(--success); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201, 160, 67, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(201, 160, 67, 0.5); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .app-header { padding: 0 1rem; }
    .app-header-title { font-size: 1rem; }
    .app-footer { font-size: 0.7rem; padding: 0 1rem; }
}
