/* MT5 and MT4 Trading Tools - Responsive Styles */

/* Base Responsive Utilities */
.product-grid,
.products-grid,
.screenshots-grid,
.related-products-grid {
    display: grid;
    gap: 1.5rem;
}

.product-card {
    overflow: hidden;
}

.product-title a,
.product-description {
    word-break: break-word;
    overflow-wrap: break-word;
}

.products-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.products-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.products-sidebar {
    width: 250px;
    flex-shrink: 0;
}

.products-main {
    flex: 1;
    min-width: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.form-control {
    width: 100%;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: 1rem;
}

/* Large Desktop (1280px and up) */
@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

/* Desktop (1024px to 1279px) */
@media (max-width: 1279px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet (768px to 1023px) */
@media (max-width: 1023px) {
    .hero h1 {
        font-size: 2.5rem;
    }

    .hero p {
        font-size: 1.125rem;
    }

    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Product Detail Page */
    .product-grid {
        grid-template-columns: 1fr !important;
    }

    .product-sidebar {
        position: relative !important;
        top: auto !important;
    }

    .product-header-flex {
        flex-direction: column !important;
    }

    .product-image {
        width: 100% !important;
        max-width: 300px !important;
        margin: 0 auto !important;
    }

    .product-badges {
        flex-wrap: wrap !important;
    }

    .product-rating {
        flex-wrap: wrap !important;
        gap: 1rem !important;
    }

    .screenshots-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .review-summary {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .review-score {
        min-width: 80px !important;
    }

    /* Products List Page */
    .products-container {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .products-sidebar {
        width: 100% !important;
        flex-shrink: 1 !important;
        margin-bottom: 0 !important;
    }

    .products-main {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    .product-card {
        min-width: 0;
    }

    .section-header {
        margin-bottom: 1.5rem !important;
    }

    .section-header h1 {
        font-size: 1.75rem !important;
        margin-bottom: 0.5rem !important;
    }

    .navbar-nav {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        background: var(--bg-dark);
        padding: 1rem;
        gap: 0;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .navbar-nav.active {
        transform: translateX(0);
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: var(--bg-darker);
        border: none;
        border-radius: 0;
        padding: 0;
        margin: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height var(--transition-normal);
    }

    .nav-item.open > .dropdown-menu {
        max-height: 500px;
    }

    .dropdown-item {
        padding: 0.75rem 1.5rem;
        border-bottom: 1px solid var(--border-color);
    }

    .dropdown-submenu > .dropdown-menu {
        left: 0;
        margin-left: 0;
    }

    .navbar-toggle {
        display: block;
    }

    .section {
        padding: 3rem 0;
    }

    .section-header h2 {
        font-size: 1.75rem;
    }

    /* Prose - Tablet */
    .prose {
        font-size: 0.95rem;
    }
    .prose h1 { font-size: 1.5rem; }
    .prose h2 { font-size: 1.3rem; }
    .prose h3 { font-size: 1.15rem; }
    .prose h4 { font-size: 1.05rem; }
    .prose h5 { font-size: 1rem; }
    .prose h6 { font-size: 0.95rem; }
    .prose ul, .prose ol {
        padding-left: 1.5rem;
    }
    .prose pre {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    .prose table {
        margin: 0.75rem 0;
        font-size: 0.85rem;
    }
    .prose th,
    .prose td {
        padding: 0.5rem;
    }
}

/* Mobile (640px to 767px) */
@media (max-width: 767px) {
    body {
        font-size: 15px;
    }

    .container {
        padding: 0 1rem;
    }

    h1 {
        font-size: 2rem;
        word-break: break-word;
    }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .hero {
        padding: 6rem 0 3rem;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .footer-brand {
        grid-column: span 1;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .modal {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        white-space: nowrap;
        padding: 0.75rem 1rem;
    }

    .product-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    .page-link {
        min-width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
    }

    /* Product Detail Page - Mobile */
    .screenshots-grid {
        grid-template-columns: 1fr !important;
    }

    .product-image {
        width: 100% !important;
        max-width: 250px !important;
    }

    .product-rating {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .related-products-grid {
        grid-template-columns: 1fr !important;
    }

    .review-summary {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .review-score div:first-child {
        font-size: 2rem !important;
    }

    .review-bars span:last-child {
        min-width: 20px !important;
        text-align: right;
    }

    /* Prose (Rich Text) - Mobile */
    .prose {
        font-size: 0.9rem;
        word-break: break-word;
        overflow-x: hidden;
    }

    .prose h1 { font-size: 1.3rem; margin-top: 1rem; }
    .prose h2 { font-size: 1.1rem; margin-top: 0.9rem; }
    .prose h3 { font-size: 1rem; margin-top: 0.8rem; }
    .prose h4, .prose h5, .prose h6 { margin-top: 0.75rem; }

    .prose ul, .prose ol {
        padding-left: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .prose li {
        margin-bottom: 0.3rem;
    }

    .prose code {
        font-size: 0.8em;
        padding: 0.15rem 0.3rem;
    }

    .prose pre {
        padding: 0.5rem;
        font-size: 0.75rem;
        overflow-x: auto;
    }

    .prose table {
        margin: 0.5rem 0;
        font-size: 0.75rem;
    }

    .prose th,
    .prose td {
        padding: 0.3rem;
    }

    /* Products List Page - Mobile */
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .section-header h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .section-header p {
        font-size: 0.9rem !important;
        margin: 0 !important;
    }

    .dropdown-item {
        display: block;
        padding: 0.5rem !important;
        border-bottom: 1px solid var(--border-color);
        word-break: break-word;
    }

    .dropdown-item:last-child {
        border-bottom: none;
    }

    .form-control {
        width: 100%;
        box-sizing: border-box;
    }

    .form-group {
        margin-bottom: 1rem;
    }
}

/* Small Mobile (up to 639px) */
@media (max-width: 639px) {
    .navbar-brand span {
        display: none;
    }

    .navbar-actions {
        gap: 0.5rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
    }

    .form-control {
        padding: 0.625rem 0.875rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .license-key {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
        text-align: center;
    }

    .license-key code {
        word-break: break-all;
    }

    /* Product Detail Page - Small Mobile */
    .product-image {
        width: 100% !important;
        max-width: 200px !important;
    }

    .prose h1 { font-size: 1.2rem; }
    .prose h2 { font-size: 1rem; }

    .prose ul, .prose ol {
        padding-left: 1rem;
    }

    /* Products List Page - Small Mobile */
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    .section-header h1 {
        font-size: 1.3rem !important;
    }

    .pagination {
        gap: 0.25rem !important;
    }

    .page-link {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
        min-width: auto;
        height: auto;
    }

    .empty-state {
        text-align: center;
        padding: 2rem 1rem;
    }

    .empty-state h3 {
        word-break: break-word;
    }

    .empty-state p {
        word-break: break-word;
    }
}

/* Prose (Rich Text Editor) Styles */
.prose {
    font-size: 1rem;
    word-break: break-word;
    overflow-x: hidden;
    line-height: 1.8;
    color: var(--text-primary);
}

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.75rem; }
.prose h3 { font-size: 1.5rem; }
.prose h4 { font-size: 1.25rem; }
.prose h5 { font-size: 1.1rem; }
.prose h6 { font-size: 1rem; }

.prose p {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.prose ul, .prose ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
    color: var(--text-primary);
}

.prose li {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.prose strong,
.prose b {
    color: var(--text-primary) !important;
    font-weight: 600 !important;
}

.prose em,
.prose i {
    color: var(--text-primary) !important;
    font-style: italic !important;
}

.prose blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.prose code {
    background: var(--bg-darker);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--text-primary);
}

.prose pre {
    background: var(--bg-darker);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.prose pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--text-primary);
}

.prose a {
    color: var(--primary);
    text-decoration: underline;
}

.prose a:hover {
    text-decoration: none;
    opacity: 0.8;
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 1rem 0;
    display: block;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
}

.prose th,
.prose td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.prose th {
    background: var(--bg-darker);
    font-weight: 600;
}

/* Quill editor styles */
.prose .ql-align-center { text-align: center; }
.prose .ql-align-right { text-align: right; }
.prose .ql-align-left { text-align: left; }

/* Star Rating Input */
.star-rating-input {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.star-rating-input label:hover,
.star-rating-input label:hover ~ label,
.star-rating-input input:checked ~ label {
    color: var(--warning) !important;
}

/* Print Styles */
@media print {
    .navbar,
    .footer,
    .btn,
    .pagination,
    .navbar-toggle {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .main-content {
        padding-top: 0;
    }

    .card {
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    a {
        color: black;
        text-decoration: underline;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --bg-dark: #000;
        --bg-card: #111;
        --border-color: #444;
        --text-primary: #fff;
        --text-secondary: #ccc;
    }
}
