/* ═══════════════════════════════════════════
   GiftlyHouse — Shared Stylesheet
   ═══════════════════════════════════════════ */

:root {
    --kawaii-pink: #D6E4FF;
    --kawaii-blue: #B8C9F2;
    --kawaii-green: #CAFFBF;
    --kawaii-purple: #C9B8F2;
    --kawaii-yellow: #FDFFB6;
    --text-dark: #2c3e50;
}

/* ── Base ── */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #F5F7FB;
    color: var(--text-dark);
    padding: 20px;
    line-height: 1.6;
}

h1, h2 { text-align: center; color: #5B7DB1; }
h3 { color: #5B7DB1; margin-top: 0; }
.container { max-width: 1200px; margin: auto; }

/* ── Navigation ── */
.nav-links {
    display: flex; justify-content: center; flex-wrap: nowrap; gap: 6px;
    margin-bottom: 25px;
    position: sticky; top: 0; z-index: 100;
    background: white; padding: 10px 0;
    border-bottom: 2px solid var(--kawaii-pink);
}
.nav-links a {
    display: inline-block;
    padding: 8px 14px;
    white-space: nowrap;
    background: white;
    border: 2px solid var(--kawaii-pink);
    border-radius: 25px;
    text-decoration: none;
    color: var(--text-dark);
    font-weight: bold;
    transition: 0.2s;
}
.nav-links a:hover, .nav-links a.active { background: var(--kawaii-pink); color: white; }

/* ── Cards ── */
.card {
    background: white;
    border: 3px solid var(--kawaii-pink);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 3px 12px rgba(44, 62, 80, 0.08);
    margin-bottom: 25px;
}

/* ── Flash Messages ── */
.flash-msg {
    background: var(--kawaii-green);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 20px;
    border: 2px solid #a8e6cf;
}

/* ── Forms ── */
label { font-weight: bold; display: block; margin-top: 10px; font-size: 0.9rem; }
input, select, textarea {
    width: 100%;
    padding: 10px;
    margin: 5px 0 10px 0;
    border: 2px solid var(--kawaii-blue);
    border-radius: 12px;
    box-sizing: border-box;
    height: 42px;
}
textarea { height: auto; }
button {
    width: 100%;
    background-color: var(--kawaii-purple);
    color: var(--text-dark);
    border: none;
    padding: 12px;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 10px;
}
button:hover { opacity: 0.8; transform: translateY(-2px); }

/* ── Search Bar ── */
.search-bar {
    display: flex; gap: 10px; margin-bottom: 25px;
    max-width: 500px; margin-left: auto; margin-right: auto;
}
.search-bar input {
    flex: 1; padding: 12px 18px; border: 2px solid var(--kawaii-blue);
    border-radius: 25px; font-size: 0.95rem; box-sizing: border-box;
    width: auto; margin: 0; height: auto;
}
.search-bar button {
    padding: 12px 25px; background: var(--kawaii-pink); color: white;
    border: none; border-radius: 25px; font-weight: bold;
    cursor: pointer; transition: 0.2s; width: auto; margin: 0;
}
.search-bar button:hover { opacity: 0.8; transform: none; }

/* ── Grid Layouts ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 25px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 30px; }

/* ── Stat Cards ── */
.stat-card {
    background: white;
    border: 3px solid var(--kawaii-blue);
    border-radius: 20px;
    padding: 18px;
    text-align: center;
    box-shadow: 0 3px 12px rgba(44, 62, 80, 0.08);
}
.stat-value { font-size: 1.8rem; font-weight: bold; color: #5B7DB1; }
.stat-label { font-size: 0.8rem; color: #888; margin-top: 4px; }
.stat-sub { font-size: 0.75rem; margin-top: 4px; }
.stat-sub.up { color: #2d6a2e; }
.stat-sub.down { color: #e74c3c; }
.stat-card.alert { border-color: #FFADAD; }
.stat-card.alert .stat-value { color: #e74c3c; }

/* ── Mini Stats Row ── */
.stats-row { display: flex; gap: 15px; margin-bottom: 25px; justify-content: center; }
.mini-stat { background: white; border: 2px solid var(--kawaii-blue); border-radius: 15px; padding: 12px 25px; text-align: center; }
.mini-stat-value { font-size: 1.4rem; font-weight: bold; color: #5B7DB1; }
.mini-stat-label { font-size: 0.8rem; color: #888; }

/* ── Tables ── */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
thead th { background: #7B8EC8; color: white; padding: 12px 15px; text-align: left; position: sticky; top: 0; }
thead th:first-child { border-radius: 12px 0 0 0; }
thead th:last-child { border-radius: 0 12px 0 0; }
tbody td { padding: 10px 15px; border-bottom: 1px solid #e0e5f0; vertical-align: top; }
tbody tr:hover { background: #F0F3FA; }

/* ── Links ── */
.detail-link { color: #5B7DB1; text-decoration: none; font-weight: bold; }
.detail-link:hover { text-decoration: underline; }
.vendor-link { color: #5B7DB1; text-decoration: none; font-weight: bold; }
.vendor-link:hover { text-decoration: underline; }
.sub-text { font-size: 0.8rem; color: #888; }
.line-item { font-size: 0.8rem; color: #777; }

/* ── Inline Edit Rows ── */
.edit-toggle {
    background: var(--kawaii-blue); color: var(--text-dark);
    border: none; padding: 5px 12px; border-radius: 10px;
    font-size: 0.75rem; cursor: pointer; font-weight: bold;
    width: auto; margin: 0;
}
.edit-toggle:hover { opacity: 0.8; transform: none; }
.edit-row { display: none; }
.edit-row.active { display: table-row; }
.edit-row td { background: #F0F3FA; }
.edit-row input {
    padding: 6px 8px; border: 2px solid var(--kawaii-blue);
    border-radius: 8px; font-size: 0.85rem;
    box-sizing: border-box; width: 100%;
}
.edit-row .save-btn {
    background: var(--kawaii-green); border: none;
    padding: 6px 14px; border-radius: 10px;
    font-weight: bold; cursor: pointer; font-size: 0.8rem;
    width: auto; margin: 0;
}
.edit-row .save-btn:hover { transform: none; }
.edit-row .cancel-btn {
    background: #eee; border: none; width: auto; margin: 0;
    padding: 6px 14px; border-radius: 10px;
    cursor: pointer; font-size: 0.8rem;
}
.edit-row .cancel-btn:hover { transform: none; }

/* ── Badges ── */
.badge { padding: 4px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; }
.badge-po { background: var(--kawaii-purple); padding: 3px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: bold; }
.badge-cost { background: var(--kawaii-yellow); padding: 3px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: bold; }
.badge-orders { background: var(--kawaii-purple); padding: 3px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: bold; }
.badge-spent { background: var(--kawaii-green); padding: 3px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: bold; }
.badge-green { background: var(--kawaii-green); padding: 2px 8px; border-radius: 8px; font-size: 0.75rem; font-weight: bold; }
.badge-red { background: #FFADAD; padding: 2px 8px; border-radius: 8px; font-size: 0.75rem; font-weight: bold; }
.badge-yellow { background: var(--kawaii-yellow); padding: 2px 8px; border-radius: 8px; font-size: 0.75rem; font-weight: bold; }
.low-stock { background: #FFADAD; color: white; }
.in-stock { background: var(--kawaii-green); }
.status-completed { background: var(--kawaii-green); color: #2d6a2e; }
.status-pending { background: var(--kawaii-yellow); color: #7a6e00; }
.status-cancelled { background: #FFADAD; color: white; }
.status-order-confirmed { background: var(--kawaii-blue); color: white; }
.status-shipped { background: var(--kawaii-purple); color: white; }
.status-returned { background: #FFD6A5; color: #7a5000; }

/* ── Item Rows (multi-item forms) ── */
.item-row {
    display: flex; gap: 8px; align-items: flex-end;
    margin-bottom: 8px; padding: 10px;
    background: #F0F3FA; border-radius: 12px;
}
.item-row > div { flex: 1; }
.item-row .remove-btn {
    width: auto; flex: 0; background: #FFADAD; color: white;
    padding: 10px 14px; margin-top: 0; border: none;
    border-radius: 12px; font-size: 1rem; cursor: pointer;
}
.item-row .remove-btn:hover { transform: none; }

/* ── Bar Charts ── */
.bar-chart-container, .bar-chart {
    display: flex; align-items: stretch; justify-content: center; gap: 3px;
    height: 200px; padding: 10px 0;
    border-bottom: 2px solid #eee; overflow-x: auto;
}
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; min-width: 28px; max-width: 50px; }
.bar-col .bar {
    width: 100%;
    border-radius: 6px 6px 0 0; min-height: 4px;
    position: relative; cursor: pointer;
}
.bar-col .bar:hover { opacity: 0.8; }
.bar-col .bar-label {
    font-size: 0.6rem; color: #aaa; margin-top: 4px;
    writing-mode: vertical-rl; text-orientation: mixed;
    transform: rotate(180deg); max-height: 55px; overflow: hidden;
}
.bar-col .bar-tooltip {
    display: none; position: absolute; bottom: 100%; left: 50%;
    transform: translateX(-50%); background: #2c3e50; color: white;
    padding: 4px 8px; border-radius: 6px; font-size: 0.7rem;
    white-space: nowrap; z-index: 10; margin-bottom: 4px;
}
.bar-col .bar:hover .bar-tooltip { display: block; }

/* ── Horizontal Bars ── */
.h-bar { display: flex; align-items: center; margin: 5px 0; }
.h-bar-name { width: 220px; flex-shrink: 0; font-size: 0.8rem; }
.h-bar-track { flex: 1; height: 18px; background: #f0f0f0; border-radius: 9px; margin: 0 8px; overflow: hidden; min-width: 60px; }
.h-bar-fill { height: 100%; border-radius: 9px; min-width: 3px; }
.h-bar-val { font-size: 0.8rem; font-weight: bold; min-width: 90px; text-align: right; white-space: nowrap; flex-shrink: 0; }

/* ── Top Product/Vendor Bars ── */
.top-product-bar, .top-vendor-bar { display: flex; align-items: center; margin: 8px 0; }
.top-product-name, .top-vendor-name { width: 160px; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 22px; background: #f0f0f0; border-radius: 11px; margin: 0 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 11px; min-width: 4px; }
.top-product-qty, .top-vendor-cost { font-size: 0.85rem; font-weight: bold; width: 110px; text-align: right; }

/* ── Tabs ── */
.tab-bar {
    display: flex; gap: 0; border-bottom: 2px solid #eee; margin-bottom: 15px; overflow-x: auto;
}
.tab-bar button {
    width: auto; padding: 10px 20px; margin: 0;
    border: none; border-bottom: 3px solid transparent;
    background: transparent; color: #888; font-weight: bold;
    font-size: 0.85rem; cursor: pointer; transition: 0.2s;
    white-space: nowrap;
}
.tab-bar button:hover { color: var(--kawaii-pink); }
.tab-bar button.active { color: var(--kawaii-pink); border-bottom-color: var(--kawaii-pink); }
.tab-bar.sub-tabs button.active { color: var(--kawaii-blue); border-bottom-color: var(--kawaii-blue); }

/* ── Pagination ── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 15px; flex-wrap: wrap; }
.pagination button {
    width: auto; padding: 6px 12px; margin: 0;
    border: 2px solid var(--kawaii-pink); border-radius: 10px;
    background: white; color: var(--text-dark); font-weight: bold;
    font-size: 0.8rem; cursor: pointer; transition: 0.2s;
}
.pagination button:hover { background: var(--kawaii-pink); color: white; }
.pagination button.active { background: var(--kawaii-blue); color: white; border-color: var(--kawaii-blue); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; background: #f0f0f0; }

/* ── Status Forms ── */
.status-form { display: inline; }
.status-form select { width: auto; display: inline; padding: 4px 8px; font-size: 0.75rem; margin: 0; height: auto; }
.status-form button { width: auto; display: inline; padding: 4px 10px; font-size: 0.7rem; margin: 0 0 0 4px; }

/* ── Profile Pages ── */
.profile-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 20px; }
.profile-info h2 { text-align: left; margin: 0 0 5px 0; }
.profile-contact { font-size: 0.9rem; color: #666; }
.profile-contact div { margin: 3px 0; }
.address-block { background: #F0F3FA; padding: 12px 16px; border-radius: 12px; font-size: 0.9rem; margin-top: 10px; }

/* ── Section Divider ── */
.section-title {
    font-size: 1.1rem; font-weight: bold; color: #5B7DB1;
    margin: 30px 0 15px; text-align: center;
    border-bottom: 2px dashed var(--kawaii-pink); padding-bottom: 8px;
}

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    body { padding: 8px; }
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }
    .container { max-width: 100%; }

    /* Nav: horizontal scroll instead of wrapping */
    .nav-links {
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        justify-content: flex-start; padding: 8px 4px; gap: 4px;
    }
    .nav-links a { padding: 6px 10px; font-size: 0.75rem; }

    /* Grids stack to single column */
    .two-col, .three-col { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }

    /* Stat cards */
    .stat-card { padding: 12px; }
    .stat-value { font-size: 1.3rem; }

    /* Cards */
    .card { padding: 14px; border-radius: 14px; }

    /* Tables: ensure horizontal scroll */
    table { font-size: 0.78rem; }
    thead th { padding: 8px 8px; font-size: 0.75rem; }
    tbody td { padding: 6px 8px; }

    /* Mini stats */
    .stats-row { flex-wrap: wrap; gap: 8px; }
    .mini-stat { padding: 8px 14px; }
    .mini-stat-value { font-size: 1.1rem; }

    /* Horizontal bars */
    .h-bar-name { width: 100px; font-size: 0.7rem; }
    .h-bar-val { min-width: 60px; font-size: 0.7rem; }
    .top-product-name, .top-vendor-name { width: 100px; font-size: 0.75rem; }
    .top-product-qty, .top-vendor-cost { width: 70px; font-size: 0.75rem; }

    /* Item rows (multi-item forms) stack */
    .item-row { flex-direction: column; gap: 4px; }
    .item-row > div { width: 100%; }

    /* Profile pages */
    .profile-header { flex-direction: column; }

    /* Status forms */
    .status-form select { font-size: 0.7rem; }
    .status-form button { font-size: 0.65rem; padding: 3px 8px; }

    /* Pagination */
    .pagination { gap: 2px; }
    .pagination button { padding: 4px 8px; font-size: 0.7rem; }
}
