/* MODERN UI VARIABLES */
:root {
    --tiba-primary: #111827; 
    --tiba-accent: #2563eb; 
    --tiba-accent-hover: #1d4ed8;
    --tiba-bg: #f3f4f6;
    --tiba-surface: #ffffff;
    --tiba-border: #e5e7eb;
    --tiba-text: #374151;
    --tiba-text-light: #9ca3af;
    --tiba-radius: 12px;
    --tiba-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --tiba-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

#tiba-reservation-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--tiba-bg);
    border-radius: var(--tiba-radius);
    overflow: hidden;
    max-width: 1100px;
    margin: 40px auto;
    color: var(--tiba-text);
    box-shadow: var(--tiba-shadow-lg);
}

/* LAYOUT */
.tiba-layout-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    min-height: 600px;
}

/* LEFT STAGE */
.tiba-main-stage {
    background: var(--tiba-surface);
    padding: 40px;
    display: flex;
    flex-direction: column;
}

.tiba-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    font-size: 0.9rem;
    color: var(--tiba-text-light);
}
.tiba-back-nav { cursor: pointer; display: flex; align-items: center; gap: 5px; font-weight: 500; transition: 0.2s; }
.tiba-back-nav:hover { color: var(--tiba-primary); }

.tiba-step-intro h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--tiba-primary);
    margin: 0 0 10px 0;
    line-height: 1.2;
}
.tiba-step-intro p { margin: 0 0 30px 0; color: var(--tiba-text-light); }

/* SERVICE TABS & CARDS */

/* Tab Navigation */
.tiba-service-tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    overflow-x: auto;
    padding-bottom: 5px; 
    scrollbar-width: none;
}
.tiba-service-tabs-nav::-webkit-scrollbar { display: none; } 

.tiba-tab-trigger {
    background: transparent;
    border: 1px solid var(--tiba-border);
    color: var(--tiba-text);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tiba-tab-trigger:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.tiba-tab-trigger.active {
    background: var(--tiba-primary);
    color: #fff;
    border-color: var(--tiba-primary);
}

/* Tab Content Pane */
.tiba-tab-pane {
    display: none !important; /* Force hide inactive tabs */
    animation: tibaFadeIn 0.3s ease-out forwards;
}
.tiba-tab-pane.active {
    display: block !important; /* Force show active tab */
}

@keyframes tibaFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grid */
.tiba-grid-row {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 15px;
}

.tiba-service-card input { display: none; }
.tiba-service-card .card-inner {
    position: relative;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Aligns content to left */
    min-height: 100px
}

.card-info {
    width: 100%;
    text-align: left;
    /* Prevent text from overlapping the check icon in top-right */
    padding-right: 80px; 
}

.tiba-service-card:hover .card-inner {
    border-color: #d1d5db;
    transform: translateY(-2px);
    box-shadow: var(--tiba-shadow);
}

/* Selected State */
.tiba-service-card input:checked + .card-inner {
    border-color: var(--tiba-accent);
    background: #eff6ff;
    box-shadow: 0 0 0 2px var(--tiba-accent);
}

.service-title { display: block; font-weight: 700; color: var(--tiba-primary); margin-bottom: 4px; font-size: 1rem; }
.service-meta { display: block; font-size: 0.85rem; color: var(--tiba-text-light); font-weight: 500; margin-bottom: 8px;}
.service-desc { font-size: 0.85rem; color: var(--tiba-text-light); line-height: 1.4; flex-grow: 1; }
.card-cost {
    position: absolute;
    top: 20px;   /* Matches container top padding */
    right: 20px; /* Matches container right padding */
    margin: 0;   /* Remove any previous margins */
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--tiba-primary);
    text-align: right;
    line-height: 1; 
}

.card-check-icon {
    top: auto;       /* Reset previous top position */
    bottom: 15px;    /* Anchor to bottom */
    right: 15px;     /* Anchor to right */
    position: absolute;
    color: var(--tiba-accent);
    opacity: 0;
    transform: scale(0.5);
    transition: 0.2s;
}
.tiba-service-card input:checked + .card-inner .card-check-icon { opacity: 1; transform: scale(1); }

/* CALENDAR STYLING (jQuery UI Override) */
.tiba-datetime-container { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }

#tiba-inline-calendar .ui-datepicker {
    width: 100%; padding: 0; border: none; background: transparent; font-family: inherit;
}
#tiba-inline-calendar .ui-datepicker-header {
    background: transparent; border: none; padding: 0 0 20px 0;
}
#tiba-inline-calendar .ui-datepicker-title {
    color: var(--tiba-primary); font-weight: 800; font-size: 1.1rem;
}
#tiba-inline-calendar .ui-datepicker-prev, #tiba-inline-calendar .ui-datepicker-next {
    top: 0px; cursor: pointer; border: 1px solid var(--tiba-border); border-radius: 8px;
    background: #fff; height: 30px; width: 30px; display: flex; justify-content: center; align-items: center;
}
#tiba-inline-calendar .ui-datepicker-prev span, #tiba-inline-calendar .ui-datepicker-next span {
    text-indent: -9999px; display: block; width: 8px; height: 8px; 
    border-left: 2px solid var(--tiba-primary); border-top: 2px solid var(--tiba-primary);
}
#tiba-inline-calendar .ui-datepicker-prev span { transform: rotate(-45deg); margin-left: 2px; }
#tiba-inline-calendar .ui-datepicker-next span { transform: rotate(135deg); margin-right: 2px; }

#tiba-inline-calendar th { text-transform: uppercase; font-size: 0.7rem; color: var(--tiba-text-light); padding-bottom: 10px; }
#tiba-inline-calendar td span, #tiba-inline-calendar td a {
    text-align: center; width: 36px; height: 36px; line-height: 36px; border-radius: 50%;
    margin: 0 auto; color: var(--tiba-primary); border: none !important; background: transparent;
    font-weight: 500; font-size: 0.9rem; transition: 0.2s;
}
#tiba-inline-calendar td a:hover { background: var(--tiba-bg); }
#tiba-inline-calendar td.ui-datepicker-current-day a {
    background: var(--tiba-primary) !important; color: #fff !important; font-weight: 700;
}
#tiba-inline-calendar td.ui-datepicker-today a {
    background: transparent; color: var(--tiba-accent); font-weight: 700; position: relative;
}
#tiba-inline-calendar td.ui-datepicker-today a::after {
    content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; background: var(--tiba-accent); border-radius: 50%;
}

/* SLOTS */
.slots-header { font-weight: 700; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; color: var(--tiba-primary); }
#tiba-slots-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-height: 350px; overflow-y: auto; padding-right: 5px; }
.tiba-time-slot {
    padding: 10px; text-align: center; border: 1px solid var(--tiba-border);
    border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; color: var(--tiba-text);
}
.tiba-time-slot:hover { border-color: var(--tiba-primary); }
.tiba-time-slot.selected { background: var(--tiba-primary); color: #fff; border-color: var(--tiba-primary); }
.tiba-empty-state { grid-column: 1 / -1; text-align: center; color: var(--tiba-text-light); padding: 40px; background: var(--tiba-bg); border-radius: 8px; border: 1px dashed var(--tiba-border); }

/* FORMS */
.tiba-form-group { margin-bottom: 20px; }
.tiba-form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; color: var(--tiba-primary); }
.input-icon-wrap { position: relative; }
.input-icon-wrap span { position: absolute; left: 15px; top: 14px; color: var(--tiba-text-light); }
.input-icon-wrap input {
    width: 100%; padding: 12px 12px 12px 40px; border: 1px solid var(--tiba-border);
    border-radius: var(--tiba-radius); font-size: 1rem; outline: none; transition: 0.2s;
    box-sizing: border-box;
}
.input-icon-wrap input:focus { border-color: var(--tiba-accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* DISCOUNT MESSAGES */
.tiba-discount-section button#tiba-discount-toggle-btn { background: none; border: none; color: var(--tiba-accent); font-weight: 600; padding: 0; cursor: pointer; font-size: 0.9rem; }
#tiba-discount-wrapper { display: none; margin-top: 10px; gap: 10px; display: flex; }
#tiba-discount-wrapper input { padding: 8px; border: 1px solid var(--tiba-border); border-radius: 6px; flex: 1; }
#tiba-discount-wrapper button { padding: 8px 15px; background: var(--tiba-bg); border: 1px solid var(--tiba-border); border-radius: 6px; cursor: pointer; }

#tiba-discount-msg { font-size: 0.8rem; margin-top: 5px; font-weight: 500; }
#tiba-discount-msg.success { color: #10b981; }
#tiba-discount-msg.error { color: #ef4444; }


/* SIDEBAR (Receipt) */
.tiba-sidebar {
    background: #fafafa;
    border-left: 1px solid var(--tiba-border);
    padding: 40px 30px;
    position: relative;
}
.tiba-sticky-summary { position: sticky; top: 20px; }
.tiba-sticky-summary h3 { margin: 0 0 25px 0; font-size: 1.1rem; font-weight: 800; color: var(--tiba-primary); }

.tiba-summary-line { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 0.95rem; }
.tiba-summary-line .label { color: var(--tiba-text-light); }
.tiba-summary-line .value { font-weight: 500; text-align: right; max-width: 60%; }

.tiba-divider { height: 1px; background: var(--tiba-border); margin: 20px 0; }
.tiba-total-row { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.4rem; color: var(--tiba-primary); margin-bottom: 30px; }

.tiba-btn-primary {
    width: 100%; background: var(--tiba-primary); color: #fff; border: none;
    padding: 16px; border-radius: var(--tiba-radius); font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: 0.2s; display: flex; justify-content: space-between; align-items: center;
}
.tiba-btn-primary:hover:not(:disabled) { background: #000; transform: translateY(-1px); }
.tiba-btn-primary:disabled { background: #d1d5db; cursor: not-allowed; opacity: 0.7; }

.tiba-secure-badge { text-align: center; margin-top: 20px; font-size: 0.8rem; color: var(--tiba-text-light); display: flex; align-items: center; justify-content: center; gap: 5px; }

/* CONFIRMATION */
.tiba-success-card { text-align: center; padding: 40px 20px; }
.success-icon { 
    width: 60px; height: 60px; background: #d1fae5; color: #059669; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    margin: 0 auto 20px; font-size: 30px; 
}
.tiba-btn-outline {
    display: inline-block; padding: 10px 20px; border: 1px solid var(--tiba-border);
    border-radius: 8px; text-decoration: none; color: var(--tiba-text); font-weight: 600; margin-top: 20px;
}

/* RESPONSIVE (Mobile Sticky Footer + Animation) */
@media (max-width: 850px) {
    .tiba-layout-grid { display: block; }

    /* Main Content Padding */
    .tiba-main-stage { 
        padding: 20px; 
        padding-bottom: 120px; /* Extra space for the footer to slide in */
    }

    /* ------- STEP 2 FIX: DATE & TIME ------- */
    /* Stack them vertically instead of 2 columns */
    .tiba-datetime-container {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    /* Add visual separation between calendar and slots */
    .tiba-slots-wrapper {
        border-top: 1px solid var(--tiba-border);
        padding-top: 30px;
    }

    /* Ensure calendar stays centered and manageable */
    #tiba-inline-calendar .ui-datepicker {
        width: 100%;
        max-width: 350px;
        margin: 0 auto;
    }
    /* --------------------------------------- */

    /* Sticky Footer - Initial State (Hidden) */
    .tiba-sidebar { 
        position: fixed; 
        bottom: 0; 
        left: 0; 
        width: 100%; 
        background: #fff; 
        border-top: 1px solid var(--tiba-border);
        box-shadow: 0 -4px 15px rgba(0,0,0,0.08); 
        z-index: 9999; 
        padding: 12px 20px;
        box-sizing: border-box;
        
        /* ANIMATION PROPERTIES */
        transform: translateY(120%); /* Move off-screen downwards */
        transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* "Springy" Pop-up effect */
        will-change: transform;
    }

    /* Active State (Visible) */
    .tiba-sidebar.is-visible {
        transform: translateY(0); /* Slide into place */
    }

    /* Internal Layout (Flexbox) */
    .tiba-sticky-summary {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 15px;
    }

    /* Clean up the UI for the small bar */
    .tiba-sticky-summary h3, 
    .tiba-summary-line, 
    .tiba-divider,
    .tiba-secure-badge,
    #tiba-discount-wrapper { 
        display: none !important; 
    } 

    /* Price Tag */
    .tiba-total-row { 
        margin: 0; 
        font-size: 1.2rem; 
        display: flex; 
        flex-direction: column; 
        line-height: 1.1;
    }
    .tiba-total-row span:first-child {
        font-size: 0.65rem;
        text-transform: uppercase;
        color: #9ca3af;
        font-weight: 700;
        margin-bottom: 2px;
    }

    /* Button */
    .tiba-actions { 
        margin: 0; 
        flex: 1; 
        max-width: 60%; 
    }
    .tiba-btn-primary {
        padding: 12px;
        font-size: 1rem;
        justify-content: center;
        margin: 0;
        width: 100%;
    }
}