/**
 * Fabric Calculator Popup Styles
 * FIXED: Opera Mobile compatibility
 * Place in: themes/twoj-motyw/css/fabric-calculator.css
 */

/* ========================================
   OVERLAY - Opera Mobile fix
   ======================================== */

.fc-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2147483647; /* Max z-index for Opera */
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-transform: translateZ(0); /* Force GPU layer */
    transform: translateZ(0);
    transition: opacity 0.2s ease;
    box-sizing: border-box;
}

/* ========================================
   POPUP
   ======================================== */

.fc-popup {
    position: relative;
    max-width: 540px;
    margin: 30px auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* ========================================
   CLOSE BUTTON
   ======================================== */

.fc-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px; /* Larger touch target */
    height: 44px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    font-size: 28px;
    line-height: 44px;
    text-align: center;
    color: white;
    cursor: pointer;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fc-close:hover,
.fc-close:active {
    background: rgba(255,255,255,0.3);
}

/* ========================================
   HEADER
   ======================================== */

.fc-header {
    padding: 32px 24px 24px;
    text-align: center;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
}

.fc-icon {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.fc-icon svg {
    stroke: white;
}

.fc-title {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    color: white;
}

.fc-subtitle {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.4;
}

/* ========================================
   ROW VISUALIZATION (Layout preview)
   ======================================== */

.fc-row-info {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
}

.fc-row-info:last-of-type {
    margin-bottom: 0;
}

.fc-row-header {
    margin-bottom: 8px;
}

.fc-row-num {
    font-size: 12px;
    font-weight: 700;
    color: #3498db;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fc-row-visual {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    height: 32px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
    border: 1px solid #ddd;
}

.fc-row-piece {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border-right: 2px solid white;
    min-width: 30px;
}

.fc-row-piece:last-child {
    border-right: none;
}

.fc-row-free {
    background: repeating-linear-gradient(
        45deg,
        #f5f5f5,
        #f5f5f5 5px,
        #e8e8e8 5px,
        #e8e8e8 10px
    );
}

.fc-row-details {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
}

.fc-row-details strong {
    color: #2c3e50;
}

/* ========================================
   FORM
   ======================================== */

.fc-form {
    padding: 24px;
}

.fc-input-group {
    margin-bottom: 18px;
}

.fc-input-group > label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* ========================================
   SELECT (DROPDOWN)
   ======================================== */

.fc-select-wrapper {
    position: relative;
}

.fc-select-wrapper select {
    width: 100%;
    padding: 14px 40px 14px 16px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.fc-select-wrapper select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.fc-select-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    pointer-events: none;
    stroke: #666;
}

/* ========================================
   RADIO BUTTONS
   ======================================== */

.fc-radio-group {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 10px;
}

.fc-radio-label {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fc-radio-label:hover,
.fc-radio-label:active {
    border-color: #3498db;
    background: #f0f7ff;
}

.fc-radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.fc-radio-label input[type="radio"]:checked + .fc-radio-custom {
    border-color: #3498db;
    background: #3498db;
}

.fc-radio-label input[type="radio"]:checked + .fc-radio-custom::after {
    opacity: 1;
    -webkit-transform: translate(-50%, -50%) scale(1);
    transform: translate(-50%, -50%) scale(1);
}

.fc-radio-label input[type="radio"]:checked ~ .fc-radio-text {
    color: #2c3e50;
    font-weight: 600;
}

.fc-radio-custom {
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-radius: 50%;
    position: relative;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.fc-radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%) scale(0);
    transform: translate(-50%, -50%) scale(0);
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    transition: all 0.2s ease;
}

.fc-radio-text {
    font-size: 14px;
    color: #555;
}

/* ========================================
   SIZE FIELDS SECTIONS
   ======================================== */

.fc-size-fields {
    margin-bottom: 18px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
}

.fc-fields-header {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

/* ========================================
   INPUT ROW (3 columns)
   ======================================== */

.fc-input-row {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    gap: 12px;
}

.fc-input-third {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    margin-bottom: 0 !important;
}

.fc-input-third label {
    font-size: 12px !important;
    margin-bottom: 6px !important;
}

/* ========================================
   INPUT WRAPPER
   ======================================== */

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

.fc-input-wrapper input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    font-size: 16px; /* Prevents zoom on iOS/Opera */
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.fc-input-wrapper input::-webkit-outer-spin-button,
.fc-input-wrapper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fc-input-wrapper input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.fc-unit {
    position: absolute;
    right: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    pointer-events: none;
}

/* ========================================
   PIECE GROUPS (Different sizes)
   ======================================== */

.fc-piece-group {
    margin-bottom: 16px;
    padding: 14px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.fc-piece-group:last-child {
    margin-bottom: 0;
}

.fc-piece-header {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.fc-piece-number {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border-radius: 50%;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.fc-piece-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* ========================================
   INFO BOX
   ======================================== */

.fc-info-box {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: start;
    -webkit-align-items: flex-start;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #e8f4fd;
    border: 1px solid #b8daff;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #0c5460;
    line-height: 1.5;
}

.fc-info-box svg {
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    stroke: #3498db;
    margin-top: 2px;
}

.fc-info-box strong {
    color: #2c3e50;
}

/* ========================================
   SUBMIT BUTTON
   ======================================== */

.fc-submit-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 10px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fc-submit-btn:hover,
.fc-submit-btn:active {
    opacity: 0.9;
}

.fc-submit-btn svg {
    stroke: white;
}

/* ========================================
   RESULT
   ======================================== */

.fc-result {
    padding: 24px;
}

.fc-result-header {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #27ae60;
}

.fc-result-header svg {
    stroke: #27ae60;
}

.fc-result-main {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #d5f4e6 0%, #a8e6cf 100%);
    border-radius: 12px;
    margin-bottom: 20px;
}

.fc-result-label {
    display: block;
    font-size: 14px;
    color: #555;
    margin-bottom: 8px;
}

.fc-result-value {
    display: block;
    font-size: 52px;
    font-weight: 700;
    color: #27ae60;
    line-height: 1;
    margin-bottom: 4px;
}

.fc-result-unit {
    display: block;
    font-size: 16px;
    color: #2d8659;
    font-weight: 500;
}

/* ========================================
   RESULT DETAILS
   ======================================== */

.fc-result-details {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.fc-detail-section {
    margin-bottom: 12px;
}

.fc-detail-section:last-child {
    margin-bottom: 0;
}

.fc-detail-title {
    font-size: 12px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.fc-detail-item {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: #555;
}

.fc-detail-item strong {
    color: #333;
    font-weight: 600;
}

.fc-detail-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 10px 0;
}

.fc-detail-warning {
    color: #e67e22 !important;
    font-weight: 500;
}

.fc-detail-warning span {
    color: #e67e22 !important;
}

.fc-detail-success {
    color: #27ae60 !important;
    font-weight: 500;
}

.fc-detail-success span {
    color: #27ae60 !important;
}

.fc-detail-highlight {
    background: #e8f4fd;
    margin: 8px -8px;
    padding: 10px 8px !important;
    border-radius: 6px;
}

.fc-detail-highlight strong {
    color: #2980b9;
    font-size: 15px;
}

.fc-detail-final {
    background: #d5f4e6;
    margin: 0 -16px -16px;
    padding: 16px !important;
    border-radius: 0 0 10px 10px;
}

/* Piece summary in results */
.fc-piece-summary {
    background: white;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #e8e8e8;
}

.fc-piece-summary:last-of-type {
    margin-bottom: 0;
}

.fc-piece-summary-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #555;
}

.fc-piece-summary-header strong {
    margin-left: auto;
    color: #2980b9;
}

.fc-piece-num {
    width: 22px;
    height: 22px;
    background: #3498db;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.fc-piece-warning {
    font-size: 11px;
    color: #e67e22;
    margin-top: 6px;
    padding-left: 32px;
}

/* ========================================
   RECALCULATE BUTTON
   ======================================== */

.fc-recalculate-btn {
    width: 100%;
    padding: 14px 24px;
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fc-recalculate-btn:hover,
.fc-recalculate-btn:active {
    background: #e8e8e8;
    border-color: #ccc;
}

.fc-recalculate-btn svg {
    stroke: #666;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 580px) {
    .fc-overlay {
        padding: 10px;
    }
    
    .fc-popup {
        margin: 15px auto;
        border-radius: 12px;
    }
    
    .fc-header {
        padding: 24px 20px 20px;
    }
    
    .fc-title {
        font-size: 20px;
    }
    
    .fc-form {
        padding: 20px;
    }
    
    .fc-result {
        padding: 20px;
    }
    
    .fc-result-value {
        font-size: 44px;
    }
    
    .fc-input-row {
        -webkit-box-orient: vertical;
        -webkit-flex-direction: column;
        flex-direction: column;
        gap: 14px;
    }
    
    .fc-input-third {
        width: 100%;
    }
    
    .fc-radio-label {
        padding: 12px 14px;
    }
    
    .fc-radio-text {
        font-size: 13px;
    }
}

/* ========================================
   LINK STYLES
   ======================================== */

.fabric-calculator-link,
[data-fabric-calculator] {
    cursor: pointer;
    color: #3498db;
    text-decoration: underline;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fabric-calculator-link:hover,
.fabric-calculator-link:active,
[data-fabric-calculator]:hover,
[data-fabric-calculator]:active {
    color: #2980b9;
}

.fabric-calculator-btn {
    display: -webkit-inline-box;
    display: -webkit-inline-flex;
    display: inline-flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fabric-calculator-btn:hover,
.fabric-calculator-btn:active {
    opacity: 0.9;
    color: white !important;
}