/* Responsive Design for CHGlobal Technology */

/* ===== Base & Improved Header Styles ===== */
.navbar {
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin: 0 auto; /* center the nav links */
}

.nav-auth {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto; /* push to the right */
}

/* Dropdown styles */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--white);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu .dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    transition: background 0.2s;
}

.dropdown-menu .dropdown-item:hover {
    background: rgba(0,0,0,0.05);
}

/* Nav links hover effect */
.nav-link {
    position: relative;
    padding: 0.5rem 0;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s;
}

.nav-link:hover::after {
    width: 100%;
}

/* User dropdown icon */
.nav-user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Buttons styling – only layout properties; colors from external framework */
.btn-login,
.btn-register {
    padding: 0.5rem 1rem;
}

/* ===== Original Responsive Styles (adjusted) ===== */

/* Large Screens */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .hero h1 {
        font-size: 4rem;
    }
    
    .section-title {
        font-size: 3rem;
    }
}

/* Tablets (768px to 1023px) */
@media (max-width: 1023px) {
    .container {
        padding: 0 15px;
    }
    
    /* Navigation */
    .nav-toggle {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        top: 80px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 80px);
        background: var(--white);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        transition: left 0.3s ease; /* changed from var(--transition) for clarity */
        box-shadow: var(--box-shadow);
        overflow-y: auto;
        z-index: 999;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-links {
        flex-direction: column;
        width: 100%;
        margin: 0;
        gap: 0;
        padding: 1rem 0; /* reduced padding for better spacing */
    }
    
    .nav-links li {
        width: 100%;
        text-align: left; /* left-aligned for mobile readability */
        border-bottom: 1px solid #f0f0f0;
    }
    
    .nav-link {
        padding: 1rem 1.5rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        font-weight: 500;
    }
    
    /* Dropdown arrow icon */
    .dropdown-toggle i {
        transition: transform 0.3s ease;
    }
    
    .dropdown.active .dropdown-toggle i {
        transform: rotate(180deg);
    }
    
    /* Mobile dropdown menu – hidden by default */
    .dropdown-menu {
        position: static;
        opacity: 0;
        visibility: hidden;
        transform: none;
        box-shadow: none;
        background: #f8f9fa;
        margin: 0;
        border-radius: 0;
        max-height: 0;
        padding: 0 1.5rem;
        overflow: hidden;
        transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
        border-left: 2px solid var(--primary-color); /* accent border */
    }
    
    /* When dropdown is active, show the menu */
    .dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
        max-height: 500px; /* large enough to fit content */
        padding: 0.5rem 1.5rem 1rem 1.5rem;
    }
    
    /* Dropdown items styling for mobile */
    .dropdown-menu .dropdown-item {
        padding: 0.75rem 0;
        border-bottom: 1px dashed rgba(0,0,0,0.05);
        font-size: 0.95rem;
    }
    
    .dropdown-menu .dropdown-item:last-child {
        border-bottom: none;
    }
    
    /* Override hover effect for touch */
    .dropdown-menu .dropdown-item:hover {
        background: transparent;
        color: var(--primary-color);
    }
    
    /* Auth section in mobile menu */
    .nav-auth {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
        padding: 1.5rem;
        border-top: 1px solid #eee;
        gap: 0.75rem;
    }
    
    .btn-login,
    .btn-register {
        margin: 0;
        display: block;
        text-align: center;
        width: 100%;
        padding: 0.75rem;
    }
    
    /* User dropdown in mobile */
    .nav-user-dropdown .dropdown-menu {
        background: #f0f0f0;
        border-left-color: var(--primary-color);
    }
    
    /* Hero Section */
    .hero {
        padding: 4rem 0;
        
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .hero p {
        font-size: 1.125rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    /* Grid Layouts */
    .grid-3 {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
    
    .grid-4 {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    /* Contact Grid */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 2rem;
    }
    
    .stat-number {
        font-size: 2.5rem;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1.5rem;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
    }
    
    /* Chatbot */
    .chatbot {
        width: 300px;
        left: 1rem;
        bottom: 1rem;
    }
    
    .chatbot-body {
        height: 350px;
    }
}

/* Mobile Phones (up to 767px) */
@media (max-width: 767px) {
    .container {
        padding: 0 10px;
    }
    
    /* Typography */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    
    .section-title {
        font-size: 2rem;
    }
    
    .section-subtitle {
        font-size: 1rem;
    }
    
    /* Buttons - only layout overrides */
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .btn-lg {
        padding: 12px 24px;
        font-size: 16px;
    }
    
    /* Navigation */
    .navbar .container {
        padding: 0.75rem 10px;
    }
    
    .nav-brand a {
        font-size: 1.25rem;
    }
    
    .logo {
        height: 35px;
    }
    
    /* Hero Section */
    .hero {
        padding: 3rem 0;
    }
    
    .hero h1 {
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .hero p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    /* Sections */
    .section {
        padding: 3rem 0;
    }
    
    .section-header {
        margin-bottom: 2rem;
    }
    
    /* Grid Layouts */
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Cards */
    .card-content {
        padding: 1rem;
    }
    
    .service-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    /* Ads Section */
    .ads-section {
        padding: 3rem 0;
    }
    
    .ads-slider {
        gap: 1rem;
        padding: 0.5rem 0;
    }
    
    .ad-card {
        flex: 0 0 280px;
    }
    
    .ad-content {
        padding: 1rem;
    }
    
    /* Price Options */
    .price-options {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    /* Stats Section */
    .stats-section {
        padding: 3rem 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .stat-label {
        font-size: 1rem;
    }
    
    /* Testimonials */
    .testimonial-card {
        padding: 1.5rem;
    }
    
    .testimonial-content {
        font-size: 1rem;
    }
    
    .testimonial-author {
        flex-direction: column;
        text-align: center;
    }
    
    .author-avatar {
        width: 50px;
        height: 50px;
    }
    
    /* FAQ Section */
    .faq-question {
        padding: 1rem;
    }
    
    .faq-question h4 {
        font-size: 1rem;
    }
    
    /* Contact Section */
    .contact-info,
    .contact-form {
        padding: 1.5rem;
    }
    
    .contact-item {
        margin-bottom: 1rem;
    }
    
    .contact-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    /* Footer */
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer-content {
        gap: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .footer-section {
        text-align: center;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .footer-bottom-links {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    /* Chatbot */
    .chatbot {
        width: calc(100vw - 2rem);
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
    
    .chatbot-body {
        height: 300px;
    }
    
    .message-content {
        max-width: 90%;
        font-size: 0.8rem;
    }
    
    /* Scroll to Top */
    .scroll-to-top {
        width: 45px;
        height: 45px;
        bottom: 5rem;
        right: 1rem;
        font-size: 1rem;
    }
    
    /* Form Elements */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.6rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Admin Responsive */
    .admin-sidebar {
        width: 100%;
        transform: translateX(-100%);
    }
    
    .admin-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .admin-main {
        margin-left: 0;
    }
    
    .mobile-sidebar-toggle {
        display: block;
    }
    
    .admin-content {
        padding: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .page-actions {
        margin-left: 0;
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Data Table Responsive */
    .data-table {
        overflow-x: auto;
    }
    
    .table {
        min-width: 600px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 2px;
    }
    
    .action-buttons .btn {
        padding: 4px 8px;
        font-size: 12px;
    }
}

/* Small Mobile Phones (up to 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 8px;
    }
    
    /* Typography */
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
    
    /* Buttons - only layout overrides */
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .hero-buttons {
        gap: 0.75rem;
    }
    
    /* Navigation */
    .nav-brand a {
        font-size: 1.125rem;
    }
    
    .logo {
        height: 30px;
    }
    
    /* Cards */
    .card-content {
        padding: 0.75rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    /* Ads */
    .ad-card {
        flex: 0 0 260px;
    }
    
    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    /* Contact */
    .contact-info,
    .contact-form {
        padding: 1rem;
    }
    
    .contact-item {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
    }
    
    /* Chatbot */
    .chatbot-body {
        height: 250px;
    }
    
    .chatbot-input {
        padding: 0.75rem;
    }
    
    /* Admin Mobile */
    .admin-content {
        padding: 0.75rem;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .quick-action {
        padding: 1rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 0 auto;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* Landscape Mobile Phones */
@media (max-width: 767px) and (orientation: landscape) {
    .hero {
        padding: 2rem 0;
    }
    
    .hero h1 {
        font-size: 1.75rem;
        margin-bottom: 0.75rem;
    }
    
    .hero p {
        margin-bottom: 1rem;
    }
    
    .section {
        padding: 2rem 0;
    }
    
    .chatbot {
        display: none; /* Hide chatbot in landscape mode on mobile */
    }
}

/* Print Styles */
@media print {
    .navbar,
    .scroll-to-top,
    .chatbot,
    .hero-buttons,
    .btn,
    .footer {
        display: none !important;
    }
    
    .main-content {
        margin-top: 0 !important;
    }
    
    .hero {
        background: none !important;
        color: var(--black) !important;
        padding: 1rem 0 !important;
    }
    
    .section {
        padding: 1rem 0 !important;
    }
    
    .card,
    .testimonial-card,
    .contact-info {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    a {
        color: var(--black) !important;
        text-decoration: underline !important;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo,
    .service-icon,
    .contact-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark Mode Media Query */
@media (prefers-color-scheme: dark) {
    :root {
        --white: #1a1a1a;
        --black: #ffffff;
        --light-bg: #2c2c2c;
        --gray: #cccccc;
    }
    
    body:not(.light-mode) {
        background-color: var(--white);
        color: var(--black);
    }
    
    body:not(.light-mode) .navbar {
        background: #2c2c2c;
    }
    
    body:not(.light-mode) .card,
    body:not(.light-mode) .contact-info,
    body:not(.light-mode) .contact-form,
    body:not(.light-mode) .testimonial-card {
        background: #333333;
        color: #ffffff;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link {
        padding: 1rem 0.75rem;
        display: block;
        width: 100%;
        font-weight: 600;
        background: #fff;
        border-radius: 12px;
        margin: 0.5rem 0;
        color: var(--primary-color);
        box-shadow: 0 2px 8px rgba(52,152,219,0.08);
        transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    }
    .nav-link:hover, .nav-link:focus {
        background: var(--primary-color);
        color: #fff;
        box-shadow: 0 4px 16px rgba(52,152,219,0.15);
    }
    }
    
    .card:hover,
    .service-card:hover,
    .portfolio-card:hover {
        transform: none; /* Disable hover transforms on touch devices */
    }
    
    .dropdown:hover .dropdown-menu {
        opacity: 0;
        visibility: hidden;
    }
    
    .dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

/* Focus Styles for Accessibility */
@media (min-width: 768px) {
    .btn:focus,
    .nav-link:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    .skip-link {
        position: absolute;
        top: -40px;
        left: 6px;
        background: var(--primary-color);
        color: white;
        padding: 8px;
        z-index: 1000;
        text-decoration: none;
        border-radius: 4px;
    }
    
    .skip-link:focus {
        top: 6px;
    }
}