/**
 * Portal Application Custom Styles
 */

/* Root Variables */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --cyan-glow: #00e5ff;
    --new-ribbon: #4fc3f7;
    --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --card-hover-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Body */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Product Cards - Netflix Style */
.product-card {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    border: var(--product-card-border-width, 2px) solid var(--product-card-border-color, transparent);
    height: 100%;
    border-radius: var(--product-card-border-radius, 8px);
    background: var(--product-card-bg-color, #181818);
}

.product-card:hover {
    border-color: var(--cyan-glow);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
    transform: scale(1.05);
    z-index: 10;
}

.product-card .card-img-top {
    height: 200px;
    object-fit: cover;
    transition: opacity 0.5s ease-in-out;
}

.product-card .card-img-top.fade-out {
    opacity: 0;
}

.product-card .card-img-top.fade-in {
    opacity: 1;
}

/* Image Container - Netflix Aspect Ratio */
.product-image-container {
    position: relative;
    overflow: hidden;
    background-color: var(--product-card-bg-color, #141414);
    display: block;
    aspect-ratio: 16/9;
}

.product-image-container img.product-image {
    width: 100%;
    height: 100%;
    /* Scale down to fit the card, never crop and never upscale a small image */
    object-fit: scale-down;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.product-image-container img.product-image.active {
    opacity: 1;
}

.no-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #555;
}

/* Favicon shown when a product has no uploaded images */
.product-favicon {
    width: 64px;
    height: 64px;
    max-width: 40%;
    max-height: 60%;
    object-fit: contain;
    /* Sit above the placeholder background, not stretched like a product image */
    position: relative;
    opacity: 1;
}

/* Product Info - the strip under the image */
.product-info {
    padding: 12px;
    background: var(--product-info-bg-color, var(--product-card-bg-color, #181818));
}

.product-title {
    font-size: var(--product-name-font-size, 0.95rem);
    font-family: var(--product-name-font-family, inherit);
    font-weight: 600;
    color: var(--product-name-color, #fff);
    margin-bottom: 4px;
    /* Text wrap - show up to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.product-description {
    font-size: var(--product-desc-font-size, 0.8rem);
    font-family: var(--product-desc-font-family, inherit);
    color: #aaa;
    margin-top: 4px;
    margin-bottom: 6px;
    /* Text wrap - show up to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.product-category {
    font-size: var(--product-desc-font-size, 0.75rem);
    font-family: var(--product-desc-font-family, inherit);
    color: var(--product-desc-color, #999);
}

/* Products Grid - Responsive Netflix Style */
.products-grid {
    display: grid;
    gap: 10px;
    padding: 10px 0;
}

/* Per-row based grid sizing */
[data-products-per-row="1"] { grid-template-columns: 1fr; }
[data-products-per-row="2"] { grid-template-columns: repeat(2, 1fr); }
[data-products-per-row="3"] { grid-template-columns: repeat(3, 1fr); }
[data-products-per-row="4"] { grid-template-columns: repeat(4, 1fr); }
[data-products-per-row="5"] { grid-template-columns: repeat(5, 1fr); }
[data-products-per-row="6"] { grid-template-columns: repeat(6, 1fr); }
[data-products-per-row="7"] { grid-template-columns: repeat(7, 1fr); }
[data-products-per-row="8"] { grid-template-columns: repeat(8, 1fr); }
[data-products-per-row="9"] { grid-template-columns: repeat(9, 1fr); }
[data-products-per-row="10"] { grid-template-columns: repeat(10, 1fr); }

@media (max-width: 1400px) {
    [data-products-per-row="7"],
    [data-products-per-row="8"],
    [data-products-per-row="9"],
    [data-products-per-row="10"] { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 1200px) {
    [data-products-per-row="5"],
    [data-products-per-row="6"],
    [data-products-per-row="7"],
    [data-products-per-row="8"],
    [data-products-per-row="9"],
    [data-products-per-row="10"] { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 992px) {
    [data-products-per-row="4"],
    [data-products-per-row="5"],
    [data-products-per-row="6"],
    [data-products-per-row="7"],
    [data-products-per-row="8"],
    [data-products-per-row="9"],
    [data-products-per-row="10"] { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    [data-products-per-row="3"],
    [data-products-per-row="4"],
    [data-products-per-row="5"],
    [data-products-per-row="6"],
    [data-products-per-row="7"],
    [data-products-per-row="8"],
    [data-products-per-row="9"],
    [data-products-per-row="10"] { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    [data-products-per-row="2"],
    [data-products-per-row="3"],
    [data-products-per-row="4"],
    [data-products-per-row="5"],
    [data-products-per-row="6"],
    [data-products-per-row="7"],
    [data-products-per-row="8"],
    [data-products-per-row="9"],
    [data-products-per-row="10"] { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Product image reordering (admin > edit product)
   --------------------------------------------------------------------------- */
.image-item {
    cursor: grab;
}

.image-item:active {
    cursor: grabbing;
}

.image-item.is-dragging {
    opacity: 0.45;
    transform: scale(0.97);
}

.image-item.is-dragging .card {
    outline: 2px dashed var(--primary-color, #0d6efd);
}

/* Buttons inside the tile are controls, not drag handles */
.image-item button {
    cursor: pointer;
}

/* ---------------------------------------------------------------------------
   Angle dial

   A rotational control for gradient angles: drag anywhere on the face, or focus
   it and use the arrow keys. Writes to the hidden input named by data-target.
   --------------------------------------------------------------------------- */
.angle-dial {
    --dial-size: 104px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    user-select: none;
    touch-action: none;
}

.angle-dial-face {
    position: relative;
    width: var(--dial-size);
    height: var(--dial-size);
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 35%, #ffffff 0%, #eef1f5 55%, #dfe4ea 100%);
    border: 2px solid #ced4da;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: grab;
}

.angle-dial-face:active {
    cursor: grabbing;
}

.angle-dial:focus-visible .angle-dial-face,
.angle-dial-face:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.45);
    outline-offset: 2px;
}

/* Pointer: rotates from the centre, 0deg points up */
.angle-dial-needle {
    position: absolute;
    top: 8%;
    left: 50%;
    width: 3px;
    height: 42%;
    margin-left: -1.5px;
    border-radius: 2px;
    background: var(--primary-color, #0d6efd);
    transform-origin: 50% 100%;
    transition: transform 0.05s linear;
}

.angle-dial-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: var(--primary-color, #0d6efd);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

/* Tick marks at the quarters */
.angle-dial-face::before,
.angle-dial-face::after {
    content: '';
    position: absolute;
    background: rgba(0, 0, 0, 0.12);
}

.angle-dial-face::before {
    top: 6px;
    bottom: 6px;
    left: 50%;
    width: 1px;
    margin-left: -0.5px;
}

.angle-dial-face::after {
    left: 6px;
    right: 6px;
    top: 50%;
    height: 1px;
    margin-top: -0.5px;
}

.angle-dial-readout {
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: #495057;
}

.angle-dial-readout strong {
    font-size: 1rem;
}

/* ---------------------------------------------------------------------------
   Form row alignment

   In a Bootstrap .row of fields, controls drift out of line when one column has
   helper text under it, or holds a checkbox instead of an input. Adding
   .form-row-aligned to the row pins every label and control to the same line.
   --------------------------------------------------------------------------- */
.form-row-aligned {
    align-items: flex-start;
}

.form-row-aligned > [class*="col"] > .form-label {
    display: block;
    min-height: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Reserves the height of a label so a control stays level with its neighbours */
.form-label-spacer {
    visibility: hidden;
}

/* A checkbox, switch or button that must sit level with the inputs beside it */
.form-control-line {
    display: flex;
    align-items: center;
    min-height: calc(1.5em + 0.75rem + 2px); /* Bootstrap .form-control height */
    margin-bottom: 0;
}

/* Bootstrap floats .form-check-input and gives it its own margin-top, which
   drags the box below the centre line once the row is flexed. Lay it out as a
   flex item instead so the box AND its label centre exactly on the inputs. */
/* No min-height here: it must not override .form-control-line-sm */
.form-check.form-control-line {
    padding-left: 0;
    gap: 0.5em;
}

.form-check.form-control-line .form-check-input {
    float: none;
    margin: 0;
    flex: 0 0 auto;
}

.form-check.form-control-line .form-check-label {
    line-height: 1.2;
    margin: 0;
}

.form-control-line.form-control-line-sm {
    min-height: calc(1.5em + 0.5rem + 2px);  /* matches .form-control-sm */
}

.form-row-aligned .form-text {
    margin-top: 0.25rem;
}

/* Legal pages (terms.php, policy.php) */
.legal-page {
    max-width: 900px;
    margin: 1rem auto 2.5rem;
    padding: 2rem 2.25rem 2.5rem;
    background: #ffffff;
    color: #212529;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    line-height: 1.65;
}

.legal-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.legal-meta {
    color: #6c757d;
    font-size: 0.875rem;
    margin-bottom: 1.75rem;
}

.legal-page h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.65rem;
}

.legal-page h2.legal-part {
    font-size: 1.3rem;
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 2px solid #e9ecef;
}

.legal-page p,
.legal-page li {
    font-size: 0.95rem;
}

.legal-page ul {
    padding-left: 1.25rem;
}

.legal-page li {
    margin-bottom: 0.4rem;
}

.legal-footer-note {
    margin-top: 2.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e9ecef;
    font-size: 0.9rem;
}

@media (max-width: 576px) {
    .legal-page {
        padding: 1.25rem;
    }
}

/* Corner ribbon (New Release, Coming Soon, Leaving Soon, In Development).
   Set at 35 degrees so the longer labels fit across the corner. */
.product-ribbon {
    position: absolute;
    top: 16px;
    left: -52px;
    width: 180px;
    padding: 5px 0;
    background-color: var(--ribbon-color, var(--new-ribbon));
    color: white;
    text-align: center;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
    transform: rotate(-35deg);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    z-index: 10;
}

/* Category Badge */
.category-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Filter Bar */
.filter-bar {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Pagination */
.pagination .page-link {
    color: var(--primary-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Admin Sidebar */
.admin-sidebar {
    min-height: calc(100vh - 56px);
    background-color: #212529;
}

.admin-sidebar .nav-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.75rem 1rem;
    border-left: 3px solid transparent;
}

.admin-sidebar .nav-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

.admin-sidebar .nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
}

/* Stats Cards */
.stat-card {
    border-left: 4px solid;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.primary {
    border-left-color: var(--primary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

/* Tables */
.table-responsive {
    border-radius: 0.5rem;
    overflow: hidden;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    white-space: nowrap;
}

/* Forms */
.form-label {
    font-weight: 500;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cyan-glow);
    box-shadow: 0 0 0 0.25rem rgba(0, 229, 255, 0.25);
}

/* Buttons */
.btn-cyan {
    background-color: var(--cyan-glow);
    border-color: var(--cyan-glow);
    color: #000;
}

.btn-cyan:hover {
    background-color: #00b8d4;
    border-color: #00b8d4;
    color: #000;
}

/* Password Strength Indicator */
.password-strength {
    height: 4px;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.password-strength.weak {
    background-color: var(--danger-color);
    width: 25%;
}

.password-strength.fair {
    background-color: var(--warning-color);
    width: 50%;
}

.password-strength.good {
    background-color: #17a2b8;
    width: 75%;
}

.password-strength.strong {
    background-color: var(--success-color);
    width: 100%;
}

/* Recovery Key Display */
.recovery-key-display {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    letter-spacing: 3px;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 2px dashed #dee2e6;
}

/* Image Preview */
.image-preview {
    max-width: 150px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 2px solid #dee2e6;
}

.image-preview-container {
    position: relative;
    display: inline-block;
    margin: 0.5rem;
}

.image-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
}

/* Activity Log */
.activity-item {
    padding: 0.75rem;
    border-left: 3px solid var(--primary-color);
    background-color: #f8f9fa;
    margin-bottom: 0.5rem;
}

.activity-item.login {
    border-left-color: var(--success-color);
}

.activity-item.logout {
    border-left-color: var(--secondary-color);
}

.activity-item.security {
    border-left-color: var(--danger-color);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .product-card .card-img-top {
        height: 150px;
    }
    
    .filter-bar {
        padding: 0.75rem;
    }
    
    .recovery-key-display {
        font-size: 1rem;
        letter-spacing: 1px;
    }
}

@media (max-width: 576px) {
    .product-card .card-img-top {
        height: 180px;
    }
    
    .product-ribbon {
        font-size: 0.62rem;
        width: 175px;
        top: 14px;
        left: -56px;
    }
}

/* Utility Classes */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.border-cyan {
    border-color: var(--cyan-glow) !important;
}

.bg-cyan-light {
    background-color: rgba(0, 229, 255, 0.1);
}

/* Animation Classes */
.fade-enter {
    opacity: 0;
}

.fade-enter-active {
    opacity: 1;
    transition: opacity 0.5s ease-in;
}

.fade-exit {
    opacity: 1;
}

.fade-exit-active {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .product-card {
        break-inside: avoid;
    }
}
