/* =========================================================
   CHATNEX — APP TEMPLATES PAGE
   File: css/components/app-templates.css
   Version: Updated for App 01 — App 07
========================================================= */


/* =========================================================
   PAGE HERO
========================================================= */

.app-template-hero {
    position: relative;
    overflow: hidden;
}

.app-template-hero::before {
    content: "";
    position: absolute;
    top: -180px;
    right: -140px;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        var(--red-glow),
        transparent 68%
    );
    pointer-events: none;
    opacity: 0.7;
}

.app-template-hero::after {
    content: "";
    position: absolute;
    bottom: -220px;
    left: -180px;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(239, 27, 35, 0.08),
        transparent 70%
    );
    pointer-events: none;
}

.app-template-hero .container {
    position: relative;
    z-index: 1;
}


/* =========================================================
   ACTIVE CATEGORY SWITCHER
========================================================= */

.app-switcher.active {
    border-color: var(--red);
    background:
        linear-gradient(
            135deg,
            rgba(239, 27, 35, 0.13),
            rgba(239, 27, 35, 0.035)
        );
    box-shadow:
        0 0 0 1px rgba(239, 27, 35, 0.12),
        0 18px 45px rgba(0, 0, 0, 0.18);
}

.app-switcher.active .category-switcher-icon,
.app-switcher.active .category-switcher-arrow {
    color: var(--red);
}


/* =========================================================
   APP DISCOVERY SECTION
========================================================= */

.app-template-discovery {
    position: relative;
}

.app-template-discovery .section-header {
    margin-bottom: 32px;
}


/* =========================================================
   FILTER BAR
========================================================= */

.template-filter-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 38px;
}

.template-filter-btn {
    appearance: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 11px 19px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition:
        color var(--transition),
        background var(--transition),
        border-color var(--transition),
        transform var(--transition),
        box-shadow var(--transition);
}

.template-filter-btn:hover {
    color: var(--white);
    border-color: rgba(239, 27, 35, 0.5);
    background: var(--bg-card);
    transform: translateY(-2px);
}

.template-filter-btn.active {
    color: var(--white);
    background: var(--red);
    border-color: var(--red);
    box-shadow:
        0 8px 24px rgba(239, 27, 35, 0.22);
}

.template-filter-btn:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 3px;
}


/* =========================================================
   APP TEMPLATE GRID
========================================================= */

.app-template-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
}


/* =========================================================
   APP TEMPLATE CARD
========================================================= */

.app-template-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 24px);
    background: var(--bg-card);
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.14);
    transition:
        transform var(--transition),
        border-color var(--transition),
        box-shadow var(--transition),
        opacity var(--transition);
}

.app-template-card:hover {
    transform: translateY(-7px);
    border-color: rgba(239, 27, 35, 0.35);
    box-shadow:
        0 26px 65px rgba(0, 0, 0, 0.2);
}

.app-template-card.is-hidden {
    display: none;
}


/* =========================================================
   APP TEMPLATE PREVIEW
========================================================= */

.app-template-preview {
    position: relative;
    min-height: 330px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 35px;
    background:
        radial-gradient(
            circle at 50% 25%,
            rgba(239, 27, 35, 0.12),
            transparent 55%
        ),
        linear-gradient(
            145deg,
            var(--bg-secondary),
            var(--bg-primary)
        );
    border-bottom: 1px solid var(--border);
}

.app-template-preview::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(
            90deg,
            transparent 49.5%,
            rgba(255, 255, 255, 0.025) 50%,
            transparent 50.5%
        );
    background-size: 44px 44px;
    mask-image: linear-gradient(
        to bottom,
        black,
        transparent
    );
    pointer-events: none;
}


/* =========================================================
   BROWSER PREVIEW
========================================================= */

.app-preview-browser {
    position: relative;
    z-index: 1;
    width: min(100%, 470px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background: #0b1116;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.38);
    transform: perspective(1100px) rotateX(2deg);
    transition: transform var(--transition);
}

.app-template-card:hover .app-preview-browser {
    transform:
        perspective(1100px)
        rotateX(0deg)
        translateY(-3px);
}

.app-preview-topbar {
    height: 30px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 11px;
    background: #151d23;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.app-preview-topbar span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5b636b;
}

.app-preview-layout {
    min-height: 235px;
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
}


/* =========================================================
   DASHBOARD PREVIEW — APP 01
========================================================= */

.app-preview-sidebar {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 18px 14px;
    background: #080d11;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.app-preview-sidebar span {
    display: block;
    width: 100%;
    height: 7px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.09);
}

.app-preview-sidebar span.active {
    background: rgba(239, 27, 35, 0.9);
}

.app-preview-main {
    padding: 19px;
}

.app-preview-title {
    width: 42%;
    height: 10px;
    margin-bottom: 17px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.2);
}

.app-preview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.app-preview-stats span {
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 7px;
    background: #10161c;
}

.app-preview-chart {
    height: 85px;
    display: flex;
    align-items: flex-end;
    gap: 7px;
    padding: 10px 9px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    background: #10161c;
}

.app-preview-chart i {
    flex: 1;
    display: block;
    min-height: 20%;
    border-radius: 3px 3px 1px 1px;
    background:
        linear-gradient(
            to top,
            rgba(239, 27, 35, 0.85),
            rgba(239, 27, 35, 0.25)
        );
}

.app-preview-chart i:nth-child(1) {
    height: 42%;
}

.app-preview-chart i:nth-child(2) {
    height: 63%;
}

.app-preview-chart i:nth-child(3) {
    height: 50%;
}

.app-preview-chart i:nth-child(4) {
    height: 78%;
}

.app-preview-chart i:nth-child(5) {
    height: 67%;
}

.app-preview-chart i:nth-child(6) {
    height: 91%;
}

.app-preview-table {
    display: grid;
    gap: 6px;
}

.app-preview-table span {
    display: block;
    height: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
}

.app-preview-table span:nth-child(1) {
    width: 90%;
}

.app-preview-table span:nth-child(2) {
    width: 72%;
}

.app-preview-table span:nth-child(3) {
    width: 82%;
}


/* =========================================================
   SAAS PREVIEW — APP 02
========================================================= */

.app-preview-saas {
    min-height: 235px;
    padding: 20px;
    background:
        linear-gradient(
            145deg,
            #10161c,
            #0b1116
        );
}

.saas-preview-header {
    width: 58%;
    height: 12px;
    margin-bottom: 23px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.17);
}

.saas-preview-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.saas-preview-content div {
    height: 115px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 9px;
    background:
        linear-gradient(
            160deg,
            #151d23,
            #10161c
        );
}

.saas-preview-content div:nth-child(2) {
    background:
        linear-gradient(
            160deg,
            rgba(239, 27, 35, 0.18),
            #10161c
        );
}

.saas-preview-footer {
    display: flex;
    gap: 9px;
    margin-top: 16px;
}

.saas-preview-footer span {
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
}

.saas-preview-footer span:first-child {
    width: 42%;
}

.saas-preview-footer span:last-child {
    width: 24%;
}


/* =========================================================
   MOBILE DEVICE PREVIEW — APP 03
========================================================= */

.app-preview-device {
    position: relative;
    z-index: 1;
    width: 185px;
    padding: 9px;
    border: 3px solid #2a3239;
    border-radius: 27px;
    background: #05080b;
    box-shadow:
        0 25px 55px rgba(0, 0, 0, 0.45);
    transform: rotate(-3deg);
    transition: transform var(--transition);
}

.app-template-card:hover .app-preview-device {
    transform: rotate(0deg) translateY(-5px);
}

.app-device-camera {
    position: absolute;
    top: 9px;
    left: 50%;
    z-index: 3;
    width: 46px;
    height: 12px;
    transform: translateX(-50%);
    border-radius: 0 0 9px 9px;
    background: #05080b;
}

.app-device-screen {
    position: relative;
    min-height: 295px;
    overflow: hidden;
    padding: 27px 13px 14px;
    border-radius: 19px;
    background:
        linear-gradient(
            160deg,
            #151d23,
            #080d11
        );
}

.finance-preview-header {
    width: 48%;
    height: 9px;
    margin-bottom: 19px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.2);
}

.finance-preview-balance {
    height: 63px;
    margin-bottom: 15px;
    border-radius: 11px;
    background:
        linear-gradient(
            135deg,
            rgba(239, 27, 35, 0.9),
            rgba(201, 16, 24, 0.55)
        );
}

.finance-preview-chart {
    height: 73px;
    display: flex;
    align-items: flex-end;
    gap: 5px;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 9px;
    background: #10161c;
}

.finance-preview-chart span {
    flex: 1;
    border-radius: 3px 3px 0 0;
    background: rgba(239, 27, 35, 0.72);
}

.finance-preview-chart span:nth-child(1) {
    height: 34%;
}

.finance-preview-chart span:nth-child(2) {
    height: 52%;
}

.finance-preview-chart span:nth-child(3) {
    height: 43%;
}

.finance-preview-chart span:nth-child(4) {
    height: 74%;
}

.finance-preview-chart span:nth-child(5) {
    height: 91%;
}

.finance-preview-items {
    display: grid;
    gap: 7px;
}

.finance-preview-items span {
    height: 24px;
    border-radius: 6px;
    background: #10161c;
    border: 1px solid rgba(255, 255, 255, 0.05);
}


/* =========================================================
   PRODUCTIVITY PREVIEW — APP 04
========================================================= */

.productivity-preview {
    position: relative;
    z-index: 1;
    width: min(100%, 470px);
    min-height: 235px;
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 13px;
    background: #0b1116;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.36);
}

.productivity-sidebar {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 20px 14px;
    background: #080d11;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.productivity-sidebar span {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.08);
}

.productivity-sidebar span:first-child {
    width: 70%;
    background: rgba(239, 27, 35, 0.8);
}

.productivity-main {
    padding: 20px;
}

.productivity-header {
    width: 45%;
    height: 11px;
    margin-bottom: 20px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.18);
}

.productivity-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
}

.productivity-columns div {
    height: 165px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    background: #10161c;
}

.productivity-columns div:nth-child(2) {
    background:
        linear-gradient(
            to bottom,
            rgba(239, 27, 35, 0.12),
            #10161c
        );
}


/* =========================================================
   EDUCATION PREVIEW — APP 05
========================================================= */

.education-preview {
    position: relative;
    z-index: 1;
    width: min(100%, 470px);
    min-height: 235px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background:
        linear-gradient(
            145deg,
            #10161c,
            #0b1116
        );
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.36);
}

.education-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 16px 19px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.education-preview-logo {
    width: 76px;
    height: 9px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.18);
}

.education-preview-profile {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background:
        linear-gradient(
            135deg,
            rgba(239, 27, 35, 0.9),
            rgba(239, 27, 35, 0.3)
        );
}

.education-preview-body {
    display: grid;
    grid-template-columns: 75px minmax(0, 1fr);
    min-height: 185px;
}

.education-preview-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 17px 12px;
    background: #080d11;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.education-preview-sidebar span {
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
}

.education-preview-sidebar span:first-child {
    width: 75%;
    background: rgba(239, 27, 35, 0.82);
}

.education-preview-content {
    padding: 17px;
}

.education-preview-title {
    width: 48%;
    height: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.18);
}

.education-preview-courses {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
}

.education-preview-course {
    min-height: 70px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    background: #151d23;
}

.education-preview-course::before {
    content: "";
    display: block;
    width: 42%;
    height: 7px;
    margin-bottom: 11px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.16);
}

.education-preview-course::after {
    content: "";
    display: block;
    width: 72%;
    height: 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
}

.education-preview-progress {
    height: 6px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.06);
}

.education-preview-progress span {
    display: block;
    width: 68%;
    height: 100%;
    border-radius: inherit;
    background: rgba(239, 27, 35, 0.78);
}


/* =========================================================
   CAD / DESIGN PREVIEW — APP 06
========================================================= */

.cad-preview {
    position: relative;
    z-index: 1;
    width: min(100%, 470px);
    min-height: 235px;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 72px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    background: #0b1116;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.4);
}

.cad-preview-toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 15px 10px;
    background: #080d11;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.cad-preview-toolbar span {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    background: #151d23;
}

.cad-preview-toolbar span.active {
    border-color: rgba(239, 27, 35, 0.55);
    background: rgba(239, 27, 35, 0.18);
}

.cad-preview-canvas {
    position: relative;
    min-width: 0;
    overflow: hidden;
    background-color: #0d1419;
    background-image:
        linear-gradient(
            rgba(255, 255, 255, 0.035) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.035) 1px,
            transparent 1px
        );
    background-size: 22px 22px;
}

.cad-preview-canvas::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 105px;
    height: 70px;
    transform:
        translate(-50%, -50%)
        rotate(-10deg);
    border: 2px solid rgba(239, 27, 35, 0.72);
    box-shadow:
        35px 24px 0 -2px rgba(239, 27, 35, 0.18);
}

.cad-preview-canvas::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 135px;
    height: 1px;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.14);
    box-shadow:
        0 35px 0 rgba(255, 255, 255, 0.08);
}

.cad-preview-properties {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 15px 10px;
    background: #080d11;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.cad-preview-properties span {
    width: 100%;
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
}

.cad-preview-properties span:nth-child(1) {
    width: 72%;
    background: rgba(239, 27, 35, 0.7);
}

.cad-preview-properties span:nth-child(3) {
    width: 84%;
}

.cad-preview-properties span:nth-child(5) {
    width: 61%;
}


/* =========================================================
   MEDICAL PREVIEW — APP 07
========================================================= */

.medical-preview {
    position: relative;
    z-index: 1;
    width: min(100%, 470px);
    min-height: 235px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background:
        linear-gradient(
            145deg,
            #10161c,
            #0b1116
        );
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.36);
}

.medical-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.medical-preview-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.medical-preview-brand-icon {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: rgba(239, 27, 35, 0.18);
}

.medical-preview-brand-icon::before,
.medical-preview-brand-icon::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 3px;
    border-radius: 2px;
    background: rgba(239, 27, 35, 0.85);
}

.medical-preview-brand-icon::after {
    transform: rotate(90deg);
}

.medical-preview-brand-text {
    width: 58px;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.17);
}

.medical-preview-user {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background:
        linear-gradient(
            135deg,
            rgba(239, 27, 35, 0.8),
            rgba(239, 27, 35, 0.25)
        );
}

.medical-preview-body {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    min-height: 190px;
}

.medical-preview-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 17px 12px;
    background: #080d11;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.medical-preview-sidebar span {
    height: 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
}

.medical-preview-sidebar span:first-child {
    width: 70%;
    background: rgba(239, 27, 35, 0.8);
}

.medical-preview-content {
    padding: 17px;
}

.medical-preview-heading {
    width: 44%;
    height: 9px;
    margin-bottom: 15px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.18);
}

.medical-preview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
    margin-bottom: 11px;
}

.medical-preview-stat {
    height: 47px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 7px;
    background: #151d23;
}

.medical-preview-stat.active {
    background:
        linear-gradient(
            145deg,
            rgba(239, 27, 35, 0.18),
            #151d23
        );
}

.medical-preview-list {
    display: grid;
    gap: 7px;
}

.medical-preview-list span {
    display: block;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    background: #10161c;
}


/* =========================================================
   CARD CONTENT
========================================================= */

.app-template-content {
    padding: 27px 28px 30px;
}

.template-card-label {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 5px 10px;
    border: 1px solid rgba(239, 27, 35, 0.24);
    border-radius: 999px;
    background: rgba(239, 27, 35, 0.08);
    color: var(--red);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.09em;
}

.app-template-content h3 {
    margin: 14px 0 10px;
    color: var(--text-primary, var(--white));
    font-size: 1.35rem;
    line-height: 1.25;
}

.app-template-content p {
    margin: 0;
    max-width: 580px;
    color: var(--text-secondary);
    font-size: 0.94rem;
    line-height: 1.7;
}


/* =========================================================
   TEMPLATE TAGS
========================================================= */

.template-card-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.template-card-tags span {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    font-size: 0.7rem;
    font-weight: 700;
}


/* =========================================================
   TEMPLATE ACTIONS
========================================================= */

.template-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.template-card-actions .btn {
    min-height: 42px;
}

.template-card-actions .btn-secondary {
    border: 1px solid var(--border);
}


/* =========================================================
   EMPTY STATE
========================================================= */

.template-empty-state {
    padding: 70px 25px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg, 24px);
    background: var(--bg-card);
}

.template-empty-state[hidden] {
    display: none;
}

.empty-state-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border: 1px solid rgba(239, 27, 35, 0.25);
    border-radius: 50%;
    color: var(--red);
    background: rgba(239, 27, 35, 0.08);
    font-size: 1.4rem;
}

.template-empty-state h3 {
    margin: 0 0 8px;
    color: var(--text-primary, var(--white));
    font-size: 1.3rem;
}

.template-empty-state p {
    margin: 0 0 22px;
    color: var(--text-secondary);
}


/* =========================================================
   LIGHT MODE
========================================================= */

body.light-mode .app-template-hero::before {
    opacity: 0.35;
}

body.light-mode .app-template-hero::after {
    opacity: 0.3;
}

body.light-mode .app-template-card {
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.08);
}

body.light-mode .app-template-card:hover {
    box-shadow:
        0 24px 55px rgba(0, 0, 0, 0.12);
}

body.light-mode .app-template-preview {
    background:
        radial-gradient(
            circle at 50% 25%,
            rgba(239, 27, 35, 0.08),
            transparent 55%
        ),
        linear-gradient(
            145deg,
            var(--bg-secondary),
            var(--bg-primary)
        );
}

body.light-mode .app-preview-browser,
body.light-mode .productivity-preview,
body.light-mode .education-preview,
body.light-mode .cad-preview,
body.light-mode .medical-preview {
    box-shadow:
        0 20px 45px rgba(0, 0, 0, 0.18);
}

body.light-mode .template-filter-btn {
    color: var(--text-secondary);
    background: var(--bg-card);
}

body.light-mode .template-filter-btn:hover {
    color: var(--text-primary, #111827);
    border-color: rgba(239, 27, 35, 0.4);
}

body.light-mode .template-filter-btn.active {
    color: #ffffff;
}

body.light-mode .app-template-content h3 {
    color: var(--text-primary, #111827);
}

body.light-mode .app-template-content p,
body.light-mode .template-empty-state p {
    color: var(--text-secondary);
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .app-template-card,
    .app-preview-browser,
    .app-preview-device {
        transition: none;
    }

    .app-template-card:hover {
        transform: none;
    }

    .app-template-card:hover .app-preview-browser {
        transform:
            perspective(1100px)
            rotateX(2deg);
    }

    .app-template-card:hover .app-preview-device {
        transform: rotate(-3deg);
    }
}


/* =========================================================
   TABLET
========================================================= */

@media (max-width: 900px) {

    .app-template-grid {
        grid-template-columns: 1fr;
    }

    .app-template-preview {
        min-height: 350px;
    }

    .app-preview-browser,
    .productivity-preview,
    .education-preview,
    .cad-preview,
    .medical-preview {
        max-width: 560px;
    }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 640px) {

    .template-filter-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 7px;
        margin-right: -5px;
        scrollbar-width: thin;
    }

    .template-filter-btn {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 10px 16px;
    }

    .app-template-preview {
        min-height: 285px;
        padding: 24px 15px;
    }

    .app-preview-browser {
        width: 100%;
    }

    .app-preview-layout {
        min-height: 205px;
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .app-preview-sidebar {
        padding: 15px 10px;
        gap: 9px;
    }

    .app-preview-main {
        padding: 14px;
    }

    .app-preview-stats {
        gap: 5px;
    }

    .app-preview-stats span {
        height: 35px;
    }

    .app-preview-chart {
        height: 68px;
    }

    .app-preview-saas {
        min-height: 205px;
        padding: 15px;
    }

    .saas-preview-content {
        gap: 6px;
    }

    .saas-preview-content div {
        height: 90px;
    }

    .app-preview-device {
        width: 155px;
    }

    .app-device-screen {
        min-height: 245px;
    }

    .productivity-preview {
        min-height: 205px;
        grid-template-columns: 55px minmax(0, 1fr);
    }

    .productivity-sidebar {
        padding: 15px 10px;
    }

    .productivity-main {
        padding: 15px;
    }

    .productivity-columns div {
        height: 135px;
    }

    .education-preview {
        min-height: 205px;
    }

    .education-preview-body {
        grid-template-columns: 55px minmax(0, 1fr);
    }

    .education-preview-sidebar {
        padding: 15px 9px;
    }

    .education-preview-content {
        padding: 14px;
    }

    .education-preview-courses {
        gap: 6px;
    }

    .education-preview-course {
        min-height: 62px;
    }

    .cad-preview {
        min-height: 205px;
        grid-template-columns: 48px minmax(0, 1fr) 58px;
    }

    .cad-preview-toolbar {
        padding: 12px 7px;
        gap: 7px;
    }

    .cad-preview-toolbar span {
        width: 23px;
        height: 23px;
    }

    .cad-preview-properties {
        padding: 12px 8px;
    }

    .cad-preview-canvas::before {
        width: 82px;
        height: 56px;
    }

    .cad-preview-canvas::after {
        width: 105px;
    }

    .medical-preview {
        min-height: 205px;
    }

    .medical-preview-body {
        grid-template-columns: 55px minmax(0, 1fr);
    }

    .medical-preview-sidebar {
        padding: 15px 9px;
    }

    .medical-preview-content {
        padding: 14px;
    }

    .medical-preview-stats {
        gap: 5px;
    }

    .medical-preview-stat {
        height: 40px;
    }

    .app-template-content {
        padding: 23px 20px 25px;
    }

    .app-template-content h3 {
        font-size: 1.2rem;
    }

    .app-template-content p {
        font-size: 0.88rem;
    }

    .template-card-actions {
        width: 100%;
    }

    .template-card-actions .btn {
        flex: 1;
        justify-content: center;
    }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 420px) {

    .app-template-preview {
        min-height: 255px;
    }

    .app-preview-topbar {
        height: 25px;
    }

    .app-preview-layout {
        min-height: 185px;
    }

    .app-preview-title {
        margin-bottom: 12px;
    }

    .app-preview-stats {
        display: none;
    }

    .app-preview-chart {
        height: 72px;
        margin-bottom: 10px;
    }

    .app-preview-device {
        width: 140px;
    }

    .app-device-screen {
        min-height: 220px;
    }

    .productivity-preview {
        min-height: 185px;
    }

    .productivity-columns {
        gap: 5px;
    }

    .productivity-columns div {
        height: 115px;
    }

    .education-preview {
        min-height: 185px;
    }

    .education-preview-body {
        grid-template-columns: 45px minmax(0, 1fr);
    }

    .education-preview-sidebar {
        padding: 12px 7px;
    }

    .education-preview-content {
        padding: 12px;
    }

    .education-preview-courses {
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }

    .education-preview-course {
        min-height: 55px;
        padding: 7px;
    }

    .education-preview-course::before {
        margin-bottom: 7px;
    }

    .education-preview-progress {
        margin-top: 7px;
    }

    .cad-preview {
        min-height: 185px;
        grid-template-columns: 42px minmax(0, 1fr) 48px;
    }

    .cad-preview-toolbar {
        padding: 10px 5px;
    }

    .cad-preview-toolbar span {
        width: 20px;
        height: 20px;
    }

    .cad-preview-properties {
        padding: 10px 6px;
    }

    .cad-preview-canvas::before {
        width: 70px;
        height: 46px;
    }

    .cad-preview-canvas::after {
        width: 90px;
    }

    .medical-preview {
        min-height: 185px;
    }

    .medical-preview-body {
        grid-template-columns: 45px minmax(0, 1fr);
    }

    .medical-preview-sidebar {
        padding: 12px 7px;
    }

    .medical-preview-content {
        padding: 12px;
    }

    .medical-preview-stats {
        display: none;
    }

    .medical-preview-list span {
        height: 15px;
    }

    .template-card-actions {
        flex-direction: column;
    }

    .template-card-actions .btn {
        width: 100%;
    }
}


/* =========================================================
   EXTRA SAFETY FOR VERY SMALL SCREENS
========================================================= */

@media (max-width: 360px) {

    .app-template-preview {
        padding-left: 10px;
        padding-right: 10px;
    }

    .app-template-content {
        padding-left: 16px;
        padding-right: 16px;
    }

    .app-preview-browser,
    .productivity-preview,
    .education-preview,
    .cad-preview,
    .medical-preview {
        transform: none;
    }

    .app-template-card:hover .app-preview-browser {
        transform: none;
    }

    .app-template-card:hover .app-preview-device {
        transform: translateY(-3px);
    }

    .cad-preview {
        grid-template-columns: 36px minmax(0, 1fr) 42px;
    }

    .cad-preview-toolbar span {
        width: 18px;
        height: 18px;
    }

    .cad-preview-canvas::before {
        width: 58px;
        height: 40px;
    }
}