/**
 * Modal Component Styles
 * Complete modal system with animations, backdrop, and responsive design
 *
 * @version 1.0.0
 * @requires 01-variables.css (for CSS custom properties)
 */

/* Modal Container */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-modal, 1060);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Prevent body scroll when modal is open (CSP-safe alternative to inline styles) */
body.modal-open {
    overflow: hidden !important;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop, 1050);
    animation: fadeIn 0.2s ease-in-out;
}

/* Modal Dialog */
.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 2rem auto;
    z-index: calc(var(--z-modal, 1060) + 10);
    animation: slideDown 0.3s ease-out;
}

.modal-dialog.modal-small {
    max-width: 400px;
}

.modal-dialog.modal-medium {
    max-width: 600px;
}

.modal-dialog.modal-large {
    max-width: 900px;
}

/* Modal Content */
.modal-content {
    position: relative;
    background: var(--glass-white, rgba(0, 0, 0, 0.35));
    backdrop-filter: var(--glass-backdrop, blur(20px));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-2xl, 1rem);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

.modal-title {
    margin: 0;
    font-size: var(--font-size-2xl, 1.5rem);
    font-weight: var(--font-weight-bold, 700);
    color: var(--white, #fff);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-light, #9CA3AF);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-lg, 0.5rem);
    transition: var(--transition-fast, all 0.15s ease-in-out);
}

.modal-close:hover {
    background: var(--glass-white-light, rgba(0, 0, 0, 0.2));
    color: var(--white, #fff);
}

.modal-close:focus {
    outline: 2px solid var(--primary, #10B981);
    outline-offset: 2px;
}

/* Modal Body */
.modal-body {
    padding: 2rem;
    color: var(--text-secondary, #D1D5DB);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.modal-body p {
    margin-bottom: 1rem;
    line-height: var(--line-height-relaxed, 1.75);
}

.modal-body ul,
.modal-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.modal-body li {
    margin-bottom: 0.5rem;
}

.modal-body strong {
    color: var(--white, #fff);
}

.modal-body .badge {
    margin-bottom: 0.5rem;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

.modal-footer .btn {
    min-width: 100px;
}

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

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-dialog {
        max-width: calc(100% - 2rem);
        margin: 1rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1.25rem;
    }

    .modal-title {
        font-size: var(--font-size-xl, 1.25rem);
    }

    .modal-body {
        max-height: calc(100vh - 150px);
    }
}

/* Accessibility */
.modal[aria-hidden="true"] {
    display: none;
}

/* Focus trap for modals */
.modal.active * {
    outline-color: var(--primary, #10B981);
}

/* Scrollbar styling for modal body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--glass-border, rgba(255, 255, 255, 0.2));
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--glass-border, rgba(255, 255, 255, 0.3));
}

/* Tool Card Modal Specific Styles */
.tool-preview-modal .modal-dialog {
    max-width: 800px;
}

.tool-modal-content {
    padding: 0;
}

.tool-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

.tool-modal-header .badge {
    font-size: var(--font-size-sm, 0.875rem);
}

.tool-modal-header i {
    font-size: 3rem;
    color: var(--primary, #10B981);
}

.tool-modal-body {
    margin-bottom: 1.5rem;
}

.tool-modal-body p {
    margin-bottom: 1rem;
    line-height: var(--line-height-relaxed, 1.75);
}

.tool-modal-body ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1rem;
}

.tool-modal-body ul li {
    padding-left: 1.75rem;
    position: relative;
    margin-bottom: 0.75rem;
}

.tool-modal-body ul li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--primary, #10B981);
    font-weight: bold;
    font-size: 1.25rem;
}

.tool-modal-features {
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

.tool-modal-features h4 {
    font-size: var(--font-size-lg, 1.125rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--white, #fff);
    margin-bottom: 0.75rem;
}

.feature-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.feature-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    background: var(--primary-100, rgba(16, 185, 129, 0.1));
    border: 1px solid var(--primary, #10B981);
    border-radius: var(--radius-full, 9999px);
    color: var(--primary-light, #34D399);
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: var(--font-weight-medium, 500);
    text-transform: capitalize;
}

.tool-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

.tool-modal-actions .btn {
    min-width: 140px;
}

@media (max-width: 768px) {
    .tool-modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .tool-modal-actions .btn {
        width: 100%;
    }
}
