:root {
    --bg: #ffffff;
    --card: #eeeeee;
    --card-tabs: #ffffff;
    --text: #1f2933;
    --text-active: #0f766e;
    --tab-bg: #1f2937;
    --muted: #6b7280;

    --accent: #10b981;
    --accent-dark: #056e44;
    --accent-deep: #064e3b;

    --tab-pill: #1f2937;

    --shadow-header: rgba(0,0,0,0.18);
    --shadow-card: rgba(0,0,0,0.08);
    --shadow-tab-active: rgba(0,0,0,0.12);
}

body.dark {
    --bg: #111827;
    --card: #1f2937;
    --card-tabs: #111827;
    --text: #f9fafb;
    --text-active: #0f766e;
    --tab-bg: white;
    --muted: #9ca3af;

    --accent: #34d399;
    --accent-dark: #059669;
    --accent-deep: #064e3b;

    --tab-pill: #ffffff;

    --shadow-header: rgba(121, 114, 114, 0.18);
    --shadow-card: rgba(117, 111, 111, 0.08);
    --shadow-tab-active: rgba(0,0,0,0.4);
}

/* BASE */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;

    font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;

    background: var(--bg);
    color: var(--text);
}

/* HEADER */
.app-header {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));

    padding: 16px 18px;

    display: flex;
    align-items: center;
    gap: 12px;

    color: white;

    border-bottom: 1px solid rgba(255,255,255,0.1);

    box-shadow: 0 6px 18px var(--shadow-header);

    backdrop-filter: blur(10px);
}

.company-logo {
    height: 45px;
    width: auto;
}

.header-text h1 {
    margin: 0;
    font-size: 18px;
}

.header-text span {
    font-size: 12px;
    opacity: 0.85;
}

/* BODY */
#app-body {
    padding: 14px;
}

/* TABS */
.tabs {
    display: flex;
    border-bottom: 3px solid #128b55;
    align-items: flex-end;
}

.tab-button {
    flex: 1;
    padding: 4px 4px;
    border: none;
    background: var(--tab-pill);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.tab-button.active {
    background: var(--card);
    color: var(--text-active);

    border-radius: 4px 4px 0 0;
    font-weight: 700;

    box-shadow: 0 3px 10px var(--shadow-tab-active);
    transform: translateY(-1px);

    transition: all 0.6s ease;
}

.tab-button.active::after {
    content: "";
    display: block;
    height: 3px;
    margin-top: 6px;

    background: var(--accent);
    border-radius: 2px;
}

/* DARK MODE TABS */
body.dark .tab-button {
    color: #1f2937;
    background: var(--tab-pill);
}

body.dark .tab-button.active {
    background: #0f172a;
    color: var(--accent);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 3px 10px var(--shadow-tab-active);
}

/* TEMPLATE GROUP */
.template-group {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* TEMPLATE ROW */
.template-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

/* CARD */
.card {
    background: var(--card);
    color: var(--text);
    border: none;
    border-left: 5px solid var(--accent-dark);
    border-radius: 12px;
    padding: 12px;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow-card);
    transition: 0.2s;
}

.template-card {
    position: relative;
    margin-bottom: 5px;
    width: 95%;


    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-2px);
    border-left-color: var(--accent);
}

/* hover reveal */
.template-card:hover .card-footer {
    opacity: 1;
    transform: translateY(11px);
    pointer-events: auto;
}

/* BUTTON BASE */
.action-btn {
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow-card);

    font-size: 12px;
    line-height: 0.8;

    padding: 6px 10px;

    transition: transform 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-3px);
}

/* COLORS ONLY */
.delete-template-btn {
    background: var(--accent-dark);
    color: #e7e7e7;
    border-radius: 0px 0px 8px 0px;
}

.edit-template-btn {
    background: var(--accent);
    color: #e7e7e7;
}

/* TEXT */
.title {
    font-weight: 600;
    font-size: 14px;
}

.subtitle {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

body.dark .subtitle {
    color: #dee0e4;
}

/* HIDDEN */
.hidden {
    display: none;
}

/* DARK TOGGLE */
.dark-toggle {
    position: absolute;
    top: 10px;
    right: 10px;

    padding: 6px 10px;

    border-radius: 8px;
    border: 0px solid #dbdddf27;

    background: transparent;
    cursor: pointer;

    font-size: 14px;
}

/* ACTION AREA (NEW FOOTER LAYER) */
.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;

    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
}

/* SAVE TOGGLE */

.save-toggle {
    position: absolute;
    top: 40px;
    right: 10px;
    color: #eeeeee;

    padding: 6px 10px;

    border-radius: 8px;
    border: 0px solid #dbdddf27;

    background: transparent;
    cursor: pointer;

    font-size: 14px;
}

.save-toggle:hover {
    color: #34d399
}

/* SAVE TEMPLATE */
.save-box {
    width: 420px;
    max-width: 90%;

    background: var(--card);
    color: var(--text);

    border-radius: 12px;
    padding: 18px;

    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.save-section-dialog {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.save-section-dialog input {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;

    background: var(--bg);
    color: var(--text);
}

.save-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

#cancelBtn {
    background: #6b7280;
    color: white;

    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

#saveBtn {
    background: var(--accent);
    color: white;

    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}


.hidden {
  display: none;
}

.ph-box {
    width: 340px;
    max-width: 90%;

    max-height: 80vh; /* important */

    overflow-y: auto; /* important */

    background: var(--card);
    color: var(--text);

    border-radius: 12px;
    padding: 16px;

    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}


.ph-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.ph-row input {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.ph-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.ph-actions button {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

#insertTemplate {
  background: #10b981;
  color: white;
}

#skipTemplate {
  background: #6b7280;
  color: white;
}


.layout {
    display: flex;
    gap: 12px;
    margin-top: 0px;
}

/* LEFT: TYPES */
#typeSidebar {
    width: 20%;
    height: 100vh;
    flex-shrink: 0;
    background: var(--tab-bg);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 8px;
    border-right: 1px solid rgba(0,0,0,0.08);
}

/* RIGHT: MAIN AREA */
#content {
    flex: 1;
    margin-top: 20px;
    min-width: 0;
}

.type-sidebar {
    width: 20%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.type-item {
    margin-top: 10px;
    padding: 10px;
    font-size: 10px;
    background: var(--tab-pill);
    color: white;
    cursor: pointer;
    text-align: left;
    font-weight: 700;
}

.type-item.active {
    background: var(--card-tabs);
    font-weight: 800;
    color: var(--text-active);
    border-radius: 5px 0px 0px 5px;
    transform: translateX(9px);
    transition: all 0.6s ease;
    border-left: 4px solid var(--accent-dark);
}

/* DARK MODE TABS */
body.dark .type-item {
    color: #1f2937;
    background: var(--tab-pill);
}

body.dark .type-item.active {
    background: #0f172a;
    color: var(--accent);
    box-shadow: 0 3px 10px var(--shadow-tab-active);
}


.section-header {
    padding: 10px;
    background: var(--card);
    color: var(--text);
    border-bottom: 5px solid var(--accent-deep);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 6px;
}

.section-header:hover {
    border-bottom-color: var(--accent-dark);
}

.section-header.open {
    border-bottom-color: var(--accent);
}

.section-body {
    padding-left: 3%;
}


/* VERIFICATION BOX */
.verify-box {
    width: 340px;
    max-width: 90%;

    background: rgba(238, 238, 238, 0.88);
    backdrop-filter: blur(12px);

    color: var(--text);

    border-radius: 14px;
    padding: 20px;

    box-shadow: 0 10px 30px rgba(0,0,0,.25);

    border-left: 5px solid var(--accent-dark);
}


body.dark .verify-box {
    background: rgba(31, 41, 55, 0.88);
}


.verify-box h3 {
    margin-top: 0;
    color: var(--text);
}


.verify-box p {
    color: var(--muted);
    font-size: 13px;
}


.verify-box input {
    width: 100%;
    box-sizing: border-box;

    padding: 10px;

    border-radius: 8px;
    border: 1px solid rgba(128,128,128,.35);

    background: var(--bg);
    color: var(--text);

    margin-top: 10px;

    font-size: 16px;
    text-align: center;
    letter-spacing: 4px;
}


.verify-box input:focus {
    outline: none;
    border-color: var(--accent);
}


#verifyBtn {
    background: var(--accent);
    color: white;

    border: none;
    border-radius: 8px;

    padding: 9px 14px;

    cursor: pointer;

    font-weight: 600;
}


#verifyBtn:hover {
    background: var(--accent-dark);
}


#verifyMessage {
    color: #dc2626;
}