/* ===========================
   Daphne CRM Popup Styles
   =========================== */

:root {
    --daphne-primary: #007bff;
    --daphne-success: #28a745;
    --daphne-danger: #dc3545;
    --daphne-gray: #f8f9fa;
}

/* Popup Container */
.daphne-crm-popup {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --popup-delay: 5s;
    display: none;
    opacity: 0;
    visibility: hidden;
}

/* Popup Positions */
.daphne-crm-popup.position-bottom-right {
    bottom: 20px;
    right: 20px;
    max-width: 450px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
}

.daphne-crm-popup.position-bottom-left {
    bottom: 20px;
    left: 20px;
    max-width: 450px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
}

.daphne-crm-popup.position-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 550px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
}

.daphne-crm-popup.position-top-center {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 550px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
}

/* Popup Overlay (for center position) */
.daphne-crm-popup.position-center::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
}

/* Popup Content Box */
.daphne-popup-box {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: auto;
    animation-duration: 0.5s;
    animation-fill-mode: forwards;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Animations */
.daphne-popup-box.animate-fade {
    animation-name: fadeIn;
}

.daphne-popup-box.animate-slide-up {
    animation-name: slideUp;
}

.daphne-popup-box.animate-slide-down {
    animation-name: slideDown;
}

.daphne-popup-box.animate-zoom {
    animation-name: zoomIn;
}

.daphne-popup-box.animate-bounce {
    animation-name: bounceIn;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* Popup Header */
.daphne-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.daphne-popup-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.daphne-popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.daphne-popup-close:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

/* Popup Body */
.daphne-popup-body {
    padding: 25px;
}

.daphne-popup-description {
    margin: 0 0 20px 0;
    color: #555;
    font-size: 14px;
    line-height: 1.6;
}

/* Form Styles */
.daphne-popup-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.daphne-form-group {
    display: flex;
    flex-direction: column;
}

.daphne-form-group.form-row {
    flex-direction: row;
    gap: 15px;
}

.daphne-form-group.form-row .daphne-form-group {
    flex: 1;
}

.daphne-form-group label {
    font-weight: 500;
    margin-bottom: 6px;
    color: #333;
    font-size: 13px;
}

.daphne-form-group label .required {
    color: #dc3545;
    margin-left: 3px;
}

.daphne-form-group input,
.daphne-form-group select,
.daphne-form-group textarea {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.3s;
}

.daphne-form-group input:focus,
.daphne-form-group select:focus,
.daphne-form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.daphne-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Form Validation */
.daphne-form-group.has-error input,
.daphne-form-group.has-error select,
.daphne-form-group.has-error textarea {
    border-color: #dc3545;
}

.daphne-form-group.has-error .error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
}

/* Buttons */
.daphne-form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.daphne-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    flex: 1;
}

.daphne-btn-submit {
    background: var(--button-color, #007bff);
    color: white;
}

.daphne-btn-submit:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

.daphne-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.daphne-btn-close {
    background: #f0f0f0;
    color: #333;
}

.daphne-btn-close:hover {
    background: #e0e0e0;
}

/* Message */
.daphne-popup-message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    display: none;
}

.daphne-popup-message.show {
    display: block;
    animation: slideDown 0.3s;
}

.daphne-popup-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.daphne-popup-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Loading Spinner */
.daphne-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Responsive */
@media (max-width: 768px) {
    /* Mobile popup: küçük, ekranı tamamen kaplaması engelle */
    .daphne-crm-popup.position-bottom-right,
    .daphne-crm-popup.position-bottom-left {
        bottom: max(10px, env(safe-area-inset-bottom));
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 90vw;
        width: 90vw;
        max-height: calc(100vh - 20px);
        z-index: 2147483000;
    }

    .daphne-crm-popup.position-center,
    .daphne-crm-popup.position-top-center {
        top: max(10px, env(safe-area-inset-top));
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 90vw;
        width: 90vw;
        max-height: calc(100vh - 20px);
        z-index: 2147483000;
    }

    .daphne-popup-box {
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .daphne-popup-header {
        padding: 15px;
        flex-shrink: 0;
    }

    .daphne-popup-body {
        padding: 15px;
        overflow-y: auto;
        flex: 1;
    }

    .daphne-popup-title {
        font-size: 16px;
    }

    .daphne-popup-description {
        font-size: 13px;
    }

    .daphne-form-group.form-row {
        flex-direction: column;
        gap: 10px;
    }

    .daphne-form-group.form-row .daphne-form-group {
        flex: 1;
    }

    .daphne-form-buttons {
        flex-direction: column;
        gap: 8px;
        margin-top: 10px;
    }

    .daphne-btn {
        padding: 10px 16px;
        font-size: 13px;
        flex: 1;
    }

    .daphne-form-group label {
        font-size: 12px;
    }

    .daphne-form-group input,
    .daphne-form-group select,
    .daphne-form-group textarea {
        padding: 8px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    /* Çok küçük cihazlar - tablet/telefon */
    .daphne-crm-popup {
        max-width: 95vw;
        width: 95vw;
    }

    .daphne-popup-body {
        padding: 12px;
    }

    .daphne-popup-header {
        padding: 12px;
    }

    .daphne-popup-box {
        border-radius: 6px;
    }

    .daphne-form-group label {
        font-size: 11px;
    }

    .daphne-form-group input,
    .daphne-form-group select,
    .daphne-form-group textarea {
        padding: 8px;
        font-size: 11px;
    }

    .daphne-btn {
        padding: 9px 12px;
        font-size: 12px;
    }
}

/* Print Styles */
@media print {
    .daphne-crm-popup {
        display: none;
    }
}

/* Accessibility */
.daphne-popup-close:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.daphne-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Loading State */
.daphne-popup-form.loading .daphne-btn-submit {
    opacity: 0.6;
    pointer-events: none;
}

.daphne-popup-form.loading input,
.daphne-popup-form.loading select,
.daphne-popup-form.loading textarea {
    opacity: 0.6;
    pointer-events: none;
}
