/**
 * Resume Builder - Responsive Design Stylesheet
 * Mobile-first responsive design for all pages
 * Based on Kaabil LMS responsive patterns
 */

/* ========================================
   BASE RESPONSIVE UTILITIES
======================================== */

/* Container responsive widths */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1300px;
    }
}

/* ========================================
   NAVIGATION & HEADER
======================================== */

/* Hamburger Menu Button */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.navbar-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--primary-color, #7C3AED);
    margin: 5px 0;
    transition: 0.3s;
}

@media (max-width: 991px) {
    .navbar {
        padding: 0.5rem 1rem;
    }

    .navbar-content {
        flex-wrap: wrap;
    }

    .navbar-brand {
        font-size: 1.25rem;
    }

    .navbar-menu {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: calc(100vh - 60px);
        background: white;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        flex-direction: column;
        padding: 1rem;
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }

    .navbar-menu.active {
        left: 0;
    }

    .navbar-menu li {
        width: 100%;
        margin: 0.5rem 0;
    }

    .navbar-menu .navbar-link {
        display: block;
        padding: 0.75rem;
        border-radius: 4px;
    }

    .navbar-toggle {
        display: block !important;
    }

    /* Hamburger animation */
    .navbar-toggle.active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }

    .navbar-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .navbar-toggle.active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }

    /* Mobile overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        height: calc(100vh - 60px);
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .mobile-overlay.active {
        display: block;
    }
}

/* ========================================
   DASHBOARD
======================================== */

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column !important;
        text-align: center;
    }

    .dashboard-header h1 {
        font-size: 1.75rem !important;
        margin-bottom: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .resume-card {
        padding: 1rem !important;
    }

    .create-resume-card {
        padding: 2rem 1rem !important;
    }
}

@media (max-width: 576px) {
    .dashboard-container {
        padding: 1rem !important;
    }

    .resume-card h3 {
        font-size: 1rem !important;
    }

    .resume-card .resume-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .resume-card .resume-actions button {
        width: 100%;
    }
}

/* ========================================
   FORMS & INPUTS
======================================== */

@media (max-width: 768px) {
    .form-row {
        flex-direction: column !important;
    }

    .form-group {
        width: 100% !important;
        margin-right: 0 !important;
    }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    textarea,
    select {
        width: 100% !important;
        min-height: 44px; /* Touch-friendly */
    }

    .btn {
        width: 100%;
        min-height: 44px;
        margin-bottom: 0.5rem;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        border-radius: 8px !important;
        margin: 0.25rem 0;
    }
}

/* ========================================
   MODALS
======================================== */

@media (max-width: 768px) {
    .modal-overlay {
        padding: 0 !important;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .modal-header {
        padding: 1rem !important;
    }

    .modal-body {
        padding: 1rem !important;
        max-height: calc(100vh - 140px) !important;
    }

    .modal-footer {
        padding: 1rem !important;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ========================================
   CARDS & GRIDS
======================================== */

@media (max-width: 992px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .card {
        padding: 1rem !important;
    }

    .card-header {
        flex-direction: column;
        text-align: center;
    }

    .card-actions {
        width: 100%;
        justify-content: center;
        margin-top: 1rem;
    }
}

/* ========================================
   WIZARD / MULTI-STEP FORMS
======================================== */

@media (max-width: 768px) {
    .wizard-container {
        padding: 1rem !important;
    }

    .wizard-steps {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .wizard-step {
        min-width: 60px;
    }

    .wizard-step-label {
        display: none; /* Show only numbers on mobile */
    }

    .wizard-content {
        padding: 1rem !important;
    }

    .wizard-nav {
        flex-direction: column-reverse;
    }

    .wizard-nav .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
}

/* ========================================
   TEMPLATE SELECTOR
======================================== */

@media (max-width: 992px) {
    .template-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .template-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .template-card {
        height: auto !important;
    }

    .template-preview {
        height: 300px !important;
    }
}

@media (max-width: 576px) {
    .template-selector {
        overflow-x: auto;
        display: flex;
        flex-wrap: nowrap;
        gap: 1rem;
        padding-bottom: 1rem;
    }

    .template-btn {
        min-width: 120px;
    }
}

/* ========================================
   RESUME EDITOR (edit.php)
======================================== */

@media (max-width: 992px) {
    .editor-layout {
        grid-template-columns: 1fr !important;
    }

    .editor-sidebar {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        border-right: none !important;
        border-bottom: 1px solid #eee;
    }

    .section-nav {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 0.5rem;
        padding: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .section-nav-item {
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    .editor-container {
        padding: 1rem !important;
    }

    .section {
        padding: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .section-header .add-btn {
        width: 100%;
        margin-top: 1rem;
    }

    .item-card {
        padding: 1rem !important;
    }

    .item-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .item-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: 1rem;
    }

    /* Skills section */
    .skills-container {
        gap: 0.5rem !important;
    }

    .skill-tag {
        font-size: 0.85rem !important;
        padding: 0.5rem 0.75rem !important;
    }

    .skill-input-group {
        flex-direction: column !important;
    }

    .skill-input-group input {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    .skill-input-group .btn {
        width: 100% !important;
    }

    /* Sticky save button */
    .save-btn-container {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 100;
    }
}

/* ========================================
   PREVIEW PAGE
======================================== */

@media (max-width: 992px) {
    .preview-layout {
        grid-template-columns: 1fr !important;
    }

    .template-sidebar {
        width: 100% !important;
        height: auto !important;
        order: -1; /* Move template selector to top */
    }
}

@media (max-width: 768px) {
    .preview-container {
        padding: 1rem !important;
    }

    .preview-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .preview-actions .btn {
        width: 100%;
    }

    .resume-preview {
        transform: scale(0.8);
        transform-origin: top center;
    }

    .template-selector {
        padding: 1rem;
    }

    .template-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .resume-preview {
        transform: scale(0.6);
    }

    .preview-zoom-controls {
        position: fixed;
        bottom: 70px;
        right: 1rem;
        display: flex;
        gap: 0.5rem;
        z-index: 50;
    }
}

/* ========================================
   AI CHAT
======================================== */

@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 60px) !important;
        border-radius: 0 !important;
    }

    .chat-header {
        padding: 1rem !important;
        border-radius: 0 !important;
    }

    .chat-messages {
        padding: 1rem !important;
        height: calc(100vh - 200px) !important;
    }

    .message-bubble {
        max-width: 85% !important;
    }

    .chat-input-container {
        padding: 1rem !important;
        border-radius: 0 !important;
    }

    .chat-suggestions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .suggestion-chip {
        width: 100%;
        text-align: center;
    }
}

/* ========================================
   UPLOAD PAGE
======================================== */

@media (max-width: 768px) {
    .upload-container {
        padding: 1rem !important;
    }

    .upload-card {
        padding: 1.5rem !important;
    }

    .upload-zone {
        padding: 2rem 1rem !important;
    }

    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

/* ========================================
   LOGIN PAGE
======================================== */

@media (max-width: 768px) {
    .login-container {
        padding: 1rem !important;
    }

    .login-card {
        padding: 2rem 1.5rem !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    .otp-inputs {
        gap: 0.5rem !important;
    }

    .otp-input {
        width: 40px !important;
        height: 50px !important;
        font-size: 1.5rem !important;
    }

    .login-logo {
        width: 150px !important;
    }
}

/* ========================================
   TABLES
======================================== */

@media (max-width: 768px) {
    /* Convert tables to cards */
    .responsive-table {
        display: block;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody,
    .responsive-table tr {
        display: block;
        width: 100%;
    }

    .responsive-table tr {
        margin-bottom: 1rem;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 1rem;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }

    .responsive-table td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 1rem;
    }
}

/* ========================================
   UTILITY CLASSES
======================================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* Full width on mobile */
@media (max-width: 768px) {
    .mobile-full-width {
        width: 100% !important;
    }
}

/* Text alignment */
@media (max-width: 768px) {
    .mobile-text-center {
        text-align: center !important;
    }
}

/* Spacing */
@media (max-width: 768px) {
    .mobile-p-1 {
        padding: 0.5rem !important;
    }

    .mobile-p-2 {
        padding: 1rem !important;
    }

    .mobile-m-0 {
        margin: 0 !important;
    }
}

/* ========================================
   STICKY FOOTER
======================================== */

@media (max-width: 768px) {
    .sticky-footer-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 100;
        display: flex;
        gap: 0.5rem;
    }

    .sticky-footer-actions .btn {
        flex: 1;
    }

    /* Add padding to body to prevent content hiding under footer */
    body.has-sticky-footer {
        padding-bottom: 80px;
    }
}

/* ========================================
   SMOOTH SCROLLING
======================================== */

html {
    scroll-behavior: smooth;
}

@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }

    /* Smooth touch scrolling */
    .scrollable {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   PRINT STYLES (Don't break printing)
======================================== */

@media print {
    .navbar,
    .sidebar,
    .mobile-overlay,
    .sticky-footer-actions,
    .btn,
    button {
        display: none !important;
    }

    body {
        padding: 0 !important;
    }

    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
}
