/**
 * Frontend CSS - Ürün Sayfası Teslimat Sistemi
 * v3.0 - Product Page Based Design
 */

/* ========================================
   1. GENEL ALAN STIL
======================================== */

#fdm_product_delivery_fields {
    margin: 30px 0;
    padding: 25px;
    background: linear-gradient(135deg, #f5f7fa 0%, #f9fafb 100%);
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.fdm-section-title {
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    font-size: 1.5em;
    font-weight: 700;
    color: #2c3e50;
    border-bottom: 3px solid #96588a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.fdm-section-title .fdm-icon {
    font-size: 1.3em;
}

.fdm-fields-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ========================================
   2. FORM ALANLARI
======================================== */

.fdm-field-group {
    margin-bottom: 0;
}

/* Adres detayı başlangıçta gizli - adres seçilince gösterilecek */
#fdm_address_detail_group {
    display: none;
    animation: fdm-slideDown 0.3s ease-out;
}

@keyframes fdm-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
}

.fdm-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #34495e;
    margin-bottom: 8px;
}

.fdm-label .fdm-icon {
    font-size: 1.1em;
}

.fdm-label .required {
    color: #e74c3c;
    font-weight: bold;
}

.fdm-label .fdm-optional {
    font-weight: normal;
    color: #95a5a6;
    font-size: 0.9em;
}

.fdm-input,
.fdm-select,
.fdm-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #dfe6e9;
    border-radius: 8px !important;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.fdm-input:focus,
.fdm-select:focus,
.fdm-textarea:focus {
    border-color: #96588a;
    outline: none;
    box-shadow: 0 0 0 3px rgba(150, 88, 138, 0.1);
}

.fdm-input::placeholder,
.fdm-textarea::placeholder {
    color: #b2bec3;
    font-style: italic;
}

.fdm-textarea {
    resize: vertical;
    font-family: inherit;
}

/* TARİH ve SAAT - Profesyonel Görünüm */
.fdm-input[type="date"] {
    position: relative;
    padding-right: 45px;
    cursor: pointer;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%2396588a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px 20px;
    color: #2d2d2d;
    font-weight: 500;
    border-radius: 8px !important;
}

/* Modern tarih picker görünümü */
.fdm-input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: auto;
    height: auto;
    cursor: pointer;
    opacity: 0;
    z-index: 2;
}

.fdm-input[type="date"]::-webkit-datetime-edit {
    padding: 0;
}

.fdm-input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
}

.fdm-input[type="date"]:hover {
    border-color: #96588a;
    background-color: #fafafa;
}

.fdm-input[type="date"]:focus {
    border-color: #96588a;
    box-shadow: 0 0 0 3px rgba(150, 88, 138, 0.1);
    background-color: #fff;
}

/* Saat Seçici - Modern Birleşik Görünüm - YENİ TASARIM */
.fdm-time-selects {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.fdm-time-hour,
.fdm-time-minute {
    flex: 1;
    position: relative;
}

.fdm-time-hour .fdm-select,
.fdm-time-minute .fdm-select {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid #dfe6e9;
    border-radius: 8px !important;
    font-size: 15px;
    transition: all 0.3s ease;
    background-color: white;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2396588a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    font-weight: 500;
    color: #2c3e50;
}

.fdm-time-hour .fdm-select:hover,
.fdm-time-minute .fdm-select:hover {
    border-color: #96588a;
    background-color: #fafafa;
}

.fdm-time-hour .fdm-select:focus,
.fdm-time-minute .fdm-select:focus {
    border-color: #96588a;
    box-shadow: 0 0 0 3px rgba(150, 88, 138, 0.1);
    background-color: #fff;
    outline: none;
}

.fdm-time-separator {
    font-size: 20px;
    font-weight: 700;
    color: #96588a;
    user-select: none;
    padding: 0 4px;
    line-height: 1;
}

.fdm-select {
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2396588a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    padding-right: 40px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fdm-select:hover {
    border-color: #96588a;
    background-color: #fafafa;
}

.fdm-select:focus {
    border-color: #96588a;
    box-shadow: 0 0 0 3px rgba(150, 88, 138, 0.1);
    background-color: #fff;
}

/* ========================================
   3. GLOBAL ADRES ARAMA
======================================== */

.fdm-global-search-wrapper {
    position: relative;
}

.fdm-global-search-container {
    position: relative;
}

#fdm_product_address_search {
    padding-right: 45px;
    border-radius: 8px !important;
}

/* Seçilen Konum */
.fdm-selected-location {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8f2 100%);
    border: 2px solid #4caf50;
    border-radius: 8px !important;
    margin-top: 10px;
}

.fdm-selected-icon {
    font-size: 1.5em;
    color: #2e7d32;
}

.fdm-selected-text {
    flex: 1;
    color: #1b5e20;
    font-weight: 600;
    font-size: 15px;
}

.fdm-change-location {
    padding: 6px 12px;
    background: white;
    color: #1976d2;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid #1976d2;
    transition: all 0.2s;
}

.fdm-change-location:hover {
    background: #1976d2;
    color: white;
}

/* Loading */
.fdm-global-loading {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.fdm-global-loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(150, 88, 138, 0.2);
    border-radius: 50%;
    border-top-color: #96588a;
    animation: fdm-spin 0.6s linear infinite;
}

@keyframes fdm-spin {
    to { transform: rotate(360deg); }
}

/* Dropdown */
.fdm-global-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 350px;
    overflow-y: auto;
    background: white;
    border: 2px solid #96588a;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: -2px;
}

.fdm-global-results {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fdm-result-item {
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.fdm-result-item:last-child {
    border-bottom: none;
}

.fdm-result-content {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fdm-result-item:hover,
.fdm-result-item.active {
    background: linear-gradient(to right, #f8f9fa, #e8f4f8);
    border-left: 3px solid #96588a;
}

.fdm-result-item.no-results {
    color: #999;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

/* Type Icon (Emoji) */
.fdm-type-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

/* Type Badges (Deprecated - using icons now) */
.fdm-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.fdm-badge-neighborhood {
    background: #e1bee7;
    color: #6a1b9a;
}

.fdm-badge-district {
    background: #c8e6c9;
    color: #2e7d32;
}

.fdm-badge-city {
    background: #bbdefb;
    color: #1565c0;
}

.fdm-address-text {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

/* ========================================
   4. TARİH VE SAAT ALANLARI
======================================== */

.fdm-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.fdm-field-half {
    margin-bottom: 0 !important;
}

/* ========================================
   5. FİYAT ÖZETİ
======================================== */

.fdm-price-summary {
    padding: 20px;
    background: linear-gradient(135deg, #fff8e1 0%, #fffbf0 100%);
    border: 2px solid #ffa726;
    border-radius: 8px;
    margin-top: 10px;
}

.fdm-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 15px;
}

.fdm-price-row:not(:last-child) {
    border-bottom: 1px dashed #ffcc80;
}

.fdm-price-total {
    padding-top: 15px;
    margin-top: 5px;
    border-top: 2px solid #ff9800 !important;
    font-size: 18px;
    font-weight: 700;
}

.fdm-product-price {
    color: #5d4037;
    font-weight: 600;
}

/* ========================================
   6. BİLDİRİM MESAJLARI
======================================== */

.fdm-error-notice {
    padding: 15px 20px;
    background: #fff5f5;
    border-left: 4px solid #e74c3c;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #c0392b;
    animation: fdm-shake 0.5s;
}

.fdm-success-notice {
    padding: 15px 20px;
    background: #f0fdf4;
    border-left: 4px solid #22c55e;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #15803d;
    animation: fdm-slideIn 0.3s ease-out;
}

@keyframes fdm-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes fdm-slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading durumu */
.single_add_to_cart_button.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7 !important;
}

.single_add_to_cart_button.loading::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: fdm-spin 0.6s linear infinite;
}

/* ========================================
   7. RESPONSIVE TASARIM
======================================== */

@media (max-width: 768px) {
    #fdm_product_delivery_fields {
        padding: 20px 15px;
    }
    
    .fdm-section-title {
        font-size: 1.3em;
    }
    
    .fdm-field-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .fdm-field-half {
        margin-bottom: 20px;
    }
    
    .fdm-input,
    .fdm-select,
    .fdm-textarea {
        font-size: 16px; /* iOS zoom'u engelle */
    }
    
    .fdm-global-dropdown {
        max-height: 250px;
    }
    
    .fdm-selected-location {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .fdm-change-location {
        width: 100%;
        text-align: center;
    }
    
    .fdm-price-row {
        font-size: 14px;
    }
    
    .fdm-price-total {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    #fdm_product_delivery_fields {
        padding: 15px 10px;
    }
    
    .fdm-section-title {
        font-size: 1.2em;
    }
    
    .fdm-result-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .fdm-type-badge {
        font-size: 10px;
        padding: 4px 10px;
    }
}

/* ========================================
   8. SEPETE EKLE BUTONU
======================================== */

.single_add_to_cart_button.disabled {
    cursor: not-allowed !important;
    opacity: 0.5 !important;
}

/* ========================================
  8.1 SEPET / MINI CART: TESLİMAT KARTI (RESPONSIVE)
======================================== */

/* WooCommerce varyasyon listesi içinde tek kart görünümü */
.woocommerce-cart-form__cart-item .product-name dl.variation dd .fdm-delivery-card,
.ct-cart-item .variation dd .fdm-delivery-card,
.mini_cart_item .variation dd .fdm-delivery-card,
.woocommerce-checkout-review-order .product-name .variation dd .fdm-delivery-card {
    display: inline-grid;
    width: min(460px, 100%);
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.fdm-delivery-row {
    display: grid;
    grid-template-columns: 18px 66px 1fr;
    gap: 8px;
    align-items: start;
    line-height: 1.35;
}

.fdm-delivery-ico {
    width: 18px;
    text-align: center;
    font-size: 14px;
    margin-top: 1px;
}

.fdm-delivery-k {
    color: #6b7280;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.fdm-delivery-v {
    color: #111827;
    font-size: 12.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.fdm-delivery-date,
.fdm-delivery-time {
    font-weight: 700;
}

.fdm-delivery-sep {
    color: #9ca3af;
    font-weight: 600;
}

.fdm-delivery-fee {
    color: #15803d;
}

/* Sepet: "Teslimat bilgilerini düzenle" linki (buton değil) */
.fdm-cart-edit-subtotal {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
}

.fdm-cart-edit-mobile {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
}

.fdm-edit-delivery-link {
    font-size: 12.5px;
    font-weight: 600;
    color: #6b7280;
    text-decoration: underline;
    text-underline-offset: 2px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fdm-edit-delivery-link:hover {
    color: #111827;
}

@media (max-width: 420px) {
    .fdm-edit-delivery-link {
        font-size: 12px;
    }
}

/* Desktop/Mobil görünürlük yardımcıları */
.fdm-only-mobile { display: none; }
.fdm-only-desktop { display: block; }

@media (max-width: 768px) {
    .fdm-only-mobile { display: block; }
    .fdm-only-desktop { display: none; }
}

/* Sepet: ürün adının altında görünen "birim fiyat" (ikinci fiyat) desktop'ta gizle.
   Mobilde tema subtotal sütununu gizleyebildiği için mobilde dokunmuyoruz. */
@media (min-width: 769px) {
    .woocommerce-cart-form__cart-item td.product-name > .woocommerce-Price-amount,
    .woocommerce-cart-form__cart-item td.product-name > .amount,
    .woocommerce-cart-form__cart-item td.product-name .product-price,
    .woocommerce-cart-form__cart-item td.product-name .ct-cart-item-price,
    .woocommerce-cart-form__cart-item td.product-name .ct-product-price {
        display: none !important;
    }
}

/* 350px gibi dar alanlar */
@media (max-width: 420px) {
    .woocommerce-cart-form__cart-item .product-name dl.variation dd .fdm-delivery-card,
    .ct-cart-item .variation dd .fdm-delivery-card,
    .mini_cart_item .variation dd .fdm-delivery-card,
    .woocommerce-checkout-review-order .product-name .variation dd .fdm-delivery-card {
        padding: 9px 10px;
        border-radius: 9px;
        width: 100%;
    }

    .fdm-delivery-row {
        grid-template-columns: 18px 58px 1fr;
        gap: 7px;
    }

    .fdm-delivery-k {
        font-size: 11.5px;
    }

    .fdm-delivery-v {
        font-size: 12px;
    }
}

/* ========================================
   9. SCROLLBAR
======================================== */

.fdm-global-dropdown::-webkit-scrollbar {
    width: 8px;
}

.fdm-global-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.fdm-global-dropdown::-webkit-scrollbar-thumb {
    background: #96588a;
    border-radius: 4px;
}

.fdm-global-dropdown::-webkit-scrollbar-thumb:hover {
    background: #7d4772;
}

/* ========================================
   10. PRINT STYLE
======================================== */

@media print {
    #fdm_product_delivery_fields {
        background: white;
        border: 1px solid #000;
    }
    
    .fdm-change-location,
    .fdm-global-dropdown {
        display: none;
    }
}

/* ========================================
   11. ARŞİV MODAL SAYFASI
======================================== */

.fdm-archive-product-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.fdm-archive-product-info img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e1e8ed;
}

.fdm-archive-product-info h3 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
}

.fdm-archive-product-price {
    margin: 5px 0 0 0;
    font-size: 16px;
    font-weight: 700;
    color: #96588a;
}

.fdm-archive-modal-container {
    max-width: 600px;
}

.fdm-archive-modal-body {
    max-height: calc(90vh - 200px);
    overflow-y: auto;
}

.fdm-archive-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 2px solid #96588a;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: -2px;
}

.fdm-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.fdm-dropdown-item:last-child {
    border-bottom: none;
}

.fdm-dropdown-item:hover {
    background: linear-gradient(to right, #f8f9fa, #e8f4f8);
    border-left: 3px solid #96588a;
}

.fdm-no-results {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

.fdm-selected-info {
    margin-top: 10px;
    padding: 12px 15px;
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8f2 100%);
    border: 2px solid #4caf50;
    border-radius: 8px;
    color: #1b5e20;
    font-weight: 600;
}
