/* ================================================
   Branding Settings — Tabs, Designer, Previews
   ================================================ */

/* Tabs */
.branding-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.6);
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 24px;
    backdrop-filter: blur(8px);
    border: 1px solid #e2e8f0;
}

.branding-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.branding-tab:hover {
    color: #0D7377;
    background: rgba(13, 115, 119, 0.05);
}

.branding-tab.active {
    background: #fff;
    color: #0D7377;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.branding-tab i, .branding-tab svg {
    width: 18px;
    height: 18px;
}

/* Tab panels */
.tab-panel {
    display: none;
    animation: tabFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-panel.active {
    display: block;
}

@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Branding grid (identity tab) */
.branding-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .branding-grid {
        grid-template-columns: 1fr;
    }
}

/* Branding card */
.branding-card {
    border-radius: 16px;
    overflow: hidden;
}

.branding-card .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.branding-card .card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.branding-card .card-header h3 i,
.branding-card .card-header h3 svg {
    width: 18px;
    height: 18px;
    color: #0D7377;
}

.branding-card .card-body {
    padding: 20px;
}

/* Logo upload area */
.logo-upload-area {
    min-height: 200px;
}

.logo-placeholder {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #94a3b8;
}

.logo-placeholder:hover {
    border-color: #0D7377;
    background: rgba(13, 115, 119, 0.03);
    color: #0D7377;
}

.logo-placeholder i, .logo-placeholder svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.logo-placeholder p {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
}

.logo-placeholder small {
    font-size: 12px;
    opacity: 0.7;
}

.logo-preview {
    position: relative;
    text-align: center;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    background: #f8fafc;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-preview img {
    max-width: 200px;
    max-height: 150px;
    object-fit: contain;
}

.logo-preview-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.logo-preview:hover .logo-preview-overlay {
    opacity: 1;
}

/* Form actions */
.form-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-start;
}

/* Color input */
.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-input-wrap input[type="color"] {
    width: 42px;
    height: 42px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 3px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.2s;
}

.color-input-wrap input[type="color"]:hover {
    border-color: #0D7377;
}

.color-hex {
    width: 100px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    text-align: center;
}

/* Toggle switches */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: #cbd5e1;
    border-radius: 11px;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch {
    background: #0D7377;
}

.toggle-label input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(18px);
}

/* Checkbox grid */
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: #f1f5f9;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-box {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 5px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-box {
    background: #0D7377;
    border-color: #0D7377;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-box::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Form row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Form range */
.form-range {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-top: 8px;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0D7377;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(13, 115, 119, 0.3);
    transition: transform 0.2s;
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0D7377;
    border: none;
    cursor: pointer;
}

/* ================================================
   Designer Layout (side-by-side)
   ================================================ */
.designer-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1024px) {
    .designer-layout {
        grid-template-columns: 1fr;
    }
}

.designer-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.designer-preview {
    position: relative;
}

.preview-sticky {
    position: sticky;
    top: 80px;
}

.preview-title {
    font-size: 14px;
    font-weight: 700;
    color: #475569;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-title i, .preview-title svg {
    width: 16px;
    height: 16px;
    color: #0D7377;
}

.preview-label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

/* ================================================
   Carnet Preview (front & back)
   ================================================ */
.carnet-preview-front {
    width: 340px;
    height: 215px;
    background: <?= e($cd['front_bg_color']) ?>;
    color: <?= e($cd['front_text_color']) ?>;
    border-radius: 12px;
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    transition: background 0.3s, color 0.3s;
}

.cpf-club-name { text-align: center; font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.cpf-subtitle { text-align: center; font-size: 10px; opacity: 0.75; margin-bottom: 12px; }
.cpf-member-name { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.cpf-member-name-en { font-size: 10px; opacity: 0.8; margin-bottom: 6px; }
.cpf-member-number { font-size: 18px; font-weight: 700; letter-spacing: 2px; direction: ltr; text-align: right; }
.cpf-member-type { font-size: 10px; margin-top: 4px; opacity: 0.8; }
.cpf-qr {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 55px;
    height: 55px;
    background: #fff;
    border-radius: 6px;
    padding: 5px;
    transition: all 0.3s;
}
.cpf-qr svg { width: 100%; height: 100%; }
.cpf-carnet-num { position: absolute; bottom: 10px; right: 14px; font-size: 9px; opacity: 0.6; }

/* Carnet back */
.carnet-preview-back {
    width: 340px;
    height: 215px;
    background: #fff;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    padding: 14px 14px 14px 14px;
    position: relative;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    overflow: hidden;
}

.cpb-branch-strip {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 28px;
    background: <?= e($cd['back_strip_color']) ?>;
    border-radius: 12px 0 0 12px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    transition: background 0.3s;
}

.cpb-header {
    margin-right: 20px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1.5px solid #e2e8f0;
}

.cpb-logo-text {
    font-size: 10px;
    font-weight: 700;
    color: #0D7377;
    line-height: 1.4;
}

.cpb-info {
    margin-right: 20px;
    font-size: 11px;
    color: #1a1a2e;
}

.cpb-info div {
    margin-bottom: 2px;
}

.cpb-info strong {
    color: #0D7377;
}

.cpb-instructions {
    position: absolute;
    bottom: 8px;
    left: 35px;
    right: 10px;
    font-size: 9px;
    color: #94a3b8;
    text-align: center;
}

/* ================================================
   Receipt Preview
   ================================================ */
.receipt-preview {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px 20px;
    position: relative;
    overflow: hidden;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    direction: rtl;
    min-height: 400px;
}

.rp-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-size: 48px;
    font-weight: 900;
    color: #0D7377;
    opacity: <?= e($rd['watermark_opacity']) ?>;
    white-space: nowrap;
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.3s;
}

.rp-logo {
    text-align: center;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.rp-logo img {
    max-height: 40px;
    object-fit: contain;
}

.rp-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid <?= e($rd['header_color']) ?>;
    position: relative;
    z-index: 1;
    transition: border-color 0.3s;
}

.rp-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: <?= e($rd['header_color']) ?>;
    transition: color 0.3s;
}

.rp-header p {
    margin: 2px 0 0;
    font-size: 11px;
    color: #94a3b8;
}

.rp-header h3 {
    margin: 10px 0 0;
    font-size: 14px;
    color: #0f172a;
}

.rp-body {
    position: relative;
    z-index: 1;
}

.rp-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rp-body td {
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
}

.rp-label {
    background: #f8fafc;
    font-weight: 600;
    width: 35%;
    color: #475569;
}

.rp-value {
    color: #0f172a;
}

.rp-amount {
    font-size: 16px;
    font-weight: 700;
    color: #0D7377;
    direction: ltr;
    text-align: right;
}

.rp-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-top: 30px;
    text-align: center;
    font-size: 11px;
    color: #64748b;
    position: relative;
    z-index: 1;
}

.rp-signatures > div {
    border-top: 1px solid #000;
    padding-top: 8px;
}

.rp-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    position: relative;
    z-index: 1;
}

/* ================================================
   Responsive
   ================================================ */
@media (max-width: 640px) {
    .branding-tab span {
        display: none;
    }
    .branding-tabs {
        justify-content: center;
    }
    .branding-tab {
        flex: 0;
        padding: 12px 20px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
    .carnet-preview-front,
    .carnet-preview-back {
        width: 100%;
        max-width: 340px;
    }
}
