/* ==========================================================================
   MODAL DIALOGS & FORM COMPONENTS — Mobile-First (Bottom Sheets by Default)
   Single Responsibility: Modal overlay, card, headers, forms, buttons
   ========================================================================== */

/* Modal Overlay — mobile-first: align to bottom for bottom sheet */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 32, 44, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Card — mobile-first: bottom sheet style */
.modal-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    padding-bottom: calc(var(--safe-bottom) + var(--spacing-xl));
    border-bottom: none;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.open .modal-card {
    transform: translateY(0);
}

/* Bottom sheet drag indicator */
.modal-card::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    margin: 10px auto 0 auto;
}

/* Desktop: center modal */
@media (min-width: 801px) {
    .modal-overlay {
        align-items: center;
        padding: 0;
    }

    .modal-card {
        width: 430px;
        max-width: 90%;
        border-radius: var(--radius-xl);
        transform: scale(0.92) translateY(10px);
        transition: transform 0.5s cubic-bezier(0.34, 1.76, 0.64, 1), opacity 0.5s ease;
        padding-bottom: 0;
        box-shadow: 0 30px 70px rgba(0, 0, 0, 0.12), 0 0 50px rgba(255, 255, 255, 0.2);
        border-bottom: 1px solid rgba(255, 255, 255, 0.65);
        max-height: 90vh;
    }

    .modal-overlay.open .modal-card {
        transform: scale(1);
    }

    .modal-card::before {
        display: none;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 18px var(--spacing-xl);
    color: var(--white);
}

.modal-header.add-header {
    background: linear-gradient(135deg, #6C5CE7, #A29BFE);
}

.modal-header.edit-header {
    background: linear-gradient(135deg, #E17055, #FFAB91);
}

.header-icon {
    font-size: 26px !important;
    margin-right: 12px;
}

.modal-title-group h2 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.modal-title-group p {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 1px;
}

.modal-form {
    padding: var(--spacing-lg) var(--spacing-xl);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--spacing-md);
}

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dark);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 20px !important;
    pointer-events: none;
}

/* Input fields — mobile-first: larger, 16px font to prevent iOS zoom */
.input-wrapper input,
.input-wrapper select {
    width: 100%;
    height: var(--touch-target-lg);
    background-color: #F8F9FA;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: 0 12px 0 42px;
    font-family: inherit;
    font-size: 16px; /* CRITICAL: 16px prevents iOS Safari auto-zoom on focus */
    font-weight: 500;
    color: var(--text-dark);
    outline: none;
    transition: var(--transition-smooth);
    -webkit-appearance: none;
    appearance: none;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    background-color: var(--white);
}

.add-header + .modal-form .input-wrapper input:focus,
.add-header + .modal-form .input-wrapper select:focus {
    border-color: #6C5CE7;
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.edit-header + .modal-form .input-wrapper input:focus,
.edit-header + .modal-form .input-wrapper select:focus {
    border-color: #E17055;
    box-shadow: 0 0 0 3px rgba(225, 112, 85, 0.1);
}

/* Desktop: slightly smaller inputs */
@media (min-width: 801px) {
    .input-wrapper input,
    .input-wrapper select {
        height: 48px;
        font-size: 14px;
    }
}

.select-wrapper::after {
    content: "expand_more";
    font-family: 'Material Icons';
    position: absolute;
    right: 14px;
    font-size: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

/* Price Input Wrapper — ₺ prefix */
.price-input-wrapper {
    position: relative;
}

.price-prefix {
    position: absolute;
    left: 42px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
    line-height: var(--touch-target-lg);
}

.price-input-wrapper input[type="number"] {
    padding-left: 58px !important; /* icon (42px) + ₺ sign (16px) */
    font-weight: 700 !important;
    color: #00A381 !important;
}

/* Remove number input spinner arrows */
.price-input-wrapper input[type="number"]::-webkit-outer-spin-button,
.price-input-wrapper input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.price-input-wrapper input[type="number"] {
    -moz-appearance: textfield;
}

.dark-theme .price-prefix {
    color: #A0A8B5 !important;
}

.dark-theme .price-input-wrapper input[type="number"] {
    color: #00B894 !important;
}

/* Desktop line-height for price prefix */
@media (min-width: 801px) {
    .price-prefix {
        line-height: 48px;
    }

    .phone-prefix {
        line-height: 48px;
    }
}

/* Phone Input Wrapper — +90 prefix */
.phone-input-wrapper {
    position: relative;
}

.phone-prefix {
    position: absolute;
    left: 42px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
    line-height: var(--touch-target-lg);
    letter-spacing: 0.5px;
}

.phone-input-wrapper input[type="tel"] {
    padding-left: 74px !important; /* icon(42) + "+90 "(32) */
}

.dark-theme .phone-prefix {
    color: #A0A8B5 !important;
}

/* Modal Actions — mobile-first: stacked vertically */
.modal-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
    margin-top: var(--spacing-xl);
}

.actions-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* Button base — mobile-first: full width, tall */
.btn {
    height: var(--touch-target);
    padding: 0 20px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-smooth);
    width: 100%;
}

.btn:active {
    transform: scale(0.97);
}

.btn-icon { font-size: 18px !important; }

.btn-text {
    background-color: transparent;
    color: var(--text-muted);
}

.btn-text:active {
    background-color: #F1F5F9;
    color: var(--text-dark);
}

.btn-danger {
    background-color: transparent;
    color: #FF7675;
}

.btn-danger:active {
    background-color: #FFF5F5;
    color: #D63031;
}

.btn-primary {
    color: var(--white);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.btn-primary:active { transform: scale(0.97); }

.add-btn {
    background-color: #6C5CE7;
    box-shadow: 0 4px 10px rgba(108, 92, 231, 0.2);
}

.add-btn:active {
    background-color: #5B4BC4;
}

.edit-btn {
    background-color: #E17055;
    box-shadow: 0 4px 10px rgba(225, 112, 85, 0.2);
}

.edit-btn:active {
    background-color: #D05A3F;
}

/* Mobile: primary action first, cancel second, danger last */
.add-btn, .edit-btn {
    order: -1;
}

#btn-edit-close, #btn-add-cancel, #btn-custom-time-cancel {
    order: 1;
    background-color: rgba(0, 0, 0, 0.03);
}

#btn-edit-delete {
    order: 2;
    border: 1px solid rgba(255, 118, 117, 0.2);
}

/* Desktop: horizontal button layout */
@media (min-width: 801px) {
    .modal-actions {
        flex-direction: row;
        align-items: center;
    }

    .actions-right {
        flex-direction: row;
        margin-left: auto;
        width: auto;
    }

    .btn {
        width: auto;
        height: 44px;
        font-size: 14px;
    }

    .add-btn, .edit-btn {
        order: 0;
    }

    #btn-edit-close, #btn-add-cancel, #btn-custom-time-cancel {
        order: 0;
        background-color: transparent;
    }

    #btn-edit-delete {
        order: 0;
        border: none;
    }

    .btn-text:hover {
        background-color: #F1F5F9;
        color: var(--text-dark);
    }

    .btn-danger:hover {
        background-color: #FFF5F5;
        color: #D63031;
    }

    .btn-primary:hover { transform: translateY(-1px); }

    .add-btn:hover {
        background-color: #5B4BC4;
        box-shadow: 0 6px 14px rgba(108, 92, 231, 0.3);
    }

    .edit-btn:hover {
        background-color: #D05A3F;
        box-shadow: 0 6px 14px rgba(225, 112, 85, 0.3);
    }
}

.add-header + .modal-form .input-wrapper input#custom-time-input:focus {
    border-color: #FF7675;
}

/* Monthly Revenue Report Modal Styles */
.modal-header.revenue-header {
    background: linear-gradient(135deg, #6C5CE7, #0984e3);
}

.month-report-card {
    background: var(--bg-color, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-md, 12px);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.dark-theme .month-report-card {
    background: #1e2530;
    border-color: #2d3748;
}

.month-report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-color, #e2e8f0);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.month-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.month-title h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark, #1e293b);
    margin: 0;
}

.month-icon {
    color: #6C5CE7;
    font-size: 20px !important;
}

.month-total-pill {
    background: rgba(108, 92, 231, 0.12);
    color: #6C5CE7;
    font-size: 14px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
}

.dark-theme .month-total-pill {
    background: rgba(108, 92, 231, 0.25);
    color: #a29bfe;
}

.month-barber-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (max-width: 500px) {
    .month-barber-grid {
        grid-template-columns: 1fr;
    }
}

.barber-stat-item {
    background: rgba(0,0,0,0.02);
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.dark-theme .barber-stat-item {
    background: rgba(255,255,255,0.03);
}

.barber-stat-name {
    font-weight: 600;
    color: var(--text-dark, #1e293b);
}

.barber-stat-val {
    font-weight: 700;
    color: #00B894;
}

.barber-stat-val small {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 11px;
}
