/* Custom styles for the Flask SaaS application */

/* Mobile-first responsive design */
html, body {
    height: 100%;
    font-size: 16px;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.content {
    flex: 1 0 auto;
}

.footer {
    flex-shrink: 0;
    margin-top: 2rem;
}

/* Mobile Navigation Override */
.navbar-nav .nav-link {
    padding: 0.75rem 1rem !important;
    font-size: 1rem;
}

.navbar-toggler {
    border: none;
    padding: 0.5rem;
}

/* Mobile-first card styling */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1rem;
}

.card-header {
    background-color: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    padding: 0.75rem 1rem;
}

/* Organization badge styling */
.org-badge {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
}

/* Mobile-optimized buttons */
.btn-rounded {
    border-radius: 50px;
    padding: 0.75rem 1.5rem;
    min-height: 44px;
    font-size: 1rem;
}

.btn {
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.btn-success {
    background-color: #10b981;
    border-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
    border-color: #059669;
    color: white;
}

/* Touch-friendly form controls */
.form-control, .form-select {
    min-height: 44px;
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

/* Dashboard improvements - Mobile first */
.stat-card {
    text-align: center;
    padding: 1rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-card .stat-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    color: #6c757d;
}

/* Automate Geek Mobile Optimization */
.servicemate-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 1050;
    transition: left 0.3s ease;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.servicemate-sidebar.active {
    left: 0;
}

.servicemate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    display: none;
    pointer-events: auto !important;
}

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

.servicemate-mobile-header {
    display: flex !important;
    position: relative;
    z-index: 1060;
}

/* Hide mobile header on desktop */
@media (min-width: 768px) {
    .servicemate-mobile-header {
        display: none !important;
    }
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1061;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Hide navbar on Automate Geek pages */
.servicemate-page .navbar {
    display: none !important;
}

/* Hide sidebar toggle by default, show only on Automate Geek mobile pages */
.sidebar-toggle {
    display: none !important;
}

/* Show sidebar toggle only on Automate Geek pages and mobile screens */
@media (max-width: 767px) {
    .servicemate-page .sidebar-toggle {
        display: flex !important;
    }
    
    /* Ensure mobile header hamburger is visible */
    .servicemate-mobile-header .sidebar-toggle {
        display: flex !important;
        background: rgba(255, 255, 255, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        pointer-events: auto !important;
        cursor: pointer !important;
    }
}

/* Mobile sidebar header */
.servicemate-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: white;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto !important;
    z-index: 1062;
}

.sidebar-close:hover {
    background: #f3f4f6;
}

/* Mobile table optimization */
.table-responsive-mobile {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-card-view {
    display: none;
}

/* Mobile spacing adjustments */
.container {
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Tablet styles */
@media (min-width: 768px) {
    .stat-card .stat-value {
        font-size: 2rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.875rem;
    }
    
    .card {
        margin-bottom: 1.5rem;
    }
    
    /* Automate Geek desktop layout */
    .servicemate-layout .servicemate-sidebar {
        position: static !important;
        left: 0 !important;
        width: 256px;
        box-shadow: none;
        transform: none !important;
        display: flex !important;
        flex-direction: column !important;
        height: 100vh !important;
    }
    
    .servicemate-layout .servicemate-mobile-header {
        display: none !important;
    }
    
    .servicemate-layout .servicemate-overlay {
        display: none !important;
    }
    
    .servicemate-layout .servicemate-sidebar-header {
        display: none;
    }
    
    /* Desktop table/card view */
    .servicemate-layout .mobile-card-view {
        display: none;
    }
    
    .servicemate-layout .desktop-table-view {
        display: block;
    }
    
    /* Desktop dashboard grid */
    .servicemate-layout .dashboard-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .servicemate-layout .dashboard-card {
        background: white !important;
        border-radius: 0.75rem;
        padding: 1.5rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(0, 0, 0, 0.05);
    }
}

/* Desktop styles */
@media (min-width: 1024px) {
    .stat-card {
        padding: 1.5rem;
    }
    
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Large desktop dashboard grid */
    .servicemate-layout .dashboard-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .servicemate-layout .dashboard-card {
        background: white !important;
        border-radius: 0.75rem;
        padding: 1.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 2px 3px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(0, 0, 0, 0.05);
        transition: box-shadow 0.2s ease, transform 0.2s ease;
    }
    
    .servicemate-layout .dashboard-card:hover {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 4px 6px rgba(0, 0, 0, 0.1);
        transform: translateY(-1px);
    }
    
    .servicemate-layout .dashboard-card-value {
        font-size: 2.5rem;
    }
}

/* Mobile-specific Automate Geek layout */
@media (max-width: 767px) {
    .servicemate-layout {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    /* Override Tailwind classes that prevent scrolling on mobile */
    .servicemate-layout.h-screen {
        height: auto !important;
    }
    
    .servicemate-layout.overflow-hidden {
        overflow: visible !important;
    }
    
    .servicemate-layout .servicemate-main {
        padding: 0.5rem !important;
        margin-left: 0 !important;
        width: 100% !important;
        overflow-y: auto !important;
        height: auto !important;
    }
    
    /* Force sidebar to be hidden on mobile by default - only within Automate Geek */
    .servicemate-layout .servicemate-sidebar {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: -280px !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 1050 !important;
        background: white !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
        transition: left 0.3s ease !important;
    }
    
    /* Show sidebar when active - only within Automate Geek */
    .servicemate-layout .servicemate-sidebar.active {
        left: 0 !important;
    }
    
    /* Hide main content area when sidebar layout might interfere - only within Automate Geek */
    .servicemate-layout .flex.h-full.w-full {
        display: block !important;
    }
    
    /* Mobile table to card view - only within Automate Geek */
    .servicemate-layout .mobile-card-view {
        display: block;
    }
    
    .servicemate-layout .desktop-table-view {
        display: none;
    }
    
    /* Mobile work order cards */
    .work-order-card {
        background: white;
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .work-order-card-header {
        display: flex;
        justify-content: between;
        align-items: flex-start;
        margin-bottom: 0.75rem;
    }
    
    .work-order-id {
        font-weight: 600;
        color: #6366f1;
        font-size: 0.875rem;
    }
    
    .work-order-title {
        font-weight: 600;
        color: #111827;
        margin-bottom: 0.5rem;
    }
    
    .work-order-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .work-order-meta span {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        border-radius: 0.375rem;
        background: #f3f4f6;
        color: #374151;
    }
    
    .work-order-actions {
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
    }
    
    .work-order-actions a,
    .work-order-actions button {
        padding: 0.5rem 1rem;
        border-radius: 0.5rem;
        font-size: 0.875rem;
        text-decoration: none;
        border: none;
        cursor: pointer;
        min-height: 40px;
    }
    
    /* Team member cards */
    .team-member-card {
        background: white;
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .team-member-header {
        display: flex;
        align-items: center;
        margin-bottom: 0.75rem;
    }
    
    .team-member-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: #6366f1;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        margin-right: 0.75rem;
    }
    
    .team-member-info {
        flex: 1;
    }
    
    .team-member-name {
        font-weight: 600;
        color: #111827;
        margin-bottom: 0.25rem;
    }
    
    .team-member-role {
        font-size: 0.875rem;
        color: #6b7280;
    }
    
    .team-member-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-top: 0.75rem;
    }
    
    .team-stat {
        text-align: center;
        padding: 0.5rem;
        background: #f9fafb;
        border-radius: 0.5rem;
    }
    
    .team-stat-value {
        font-weight: 600;
        color: #111827;
        font-size: 1.125rem;
    }
    
    .team-stat-label {
        font-size: 0.75rem;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    /* Form optimizations for mobile */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-label {
        font-weight: 600;
        margin-bottom: 0.5rem;
        display: block;
    }
    
    /* Search and filter forms - only within Automate Geek */
    .servicemate-layout .mobile-search-form {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .servicemate-layout .mobile-search-form input,
    .servicemate-layout .mobile-search-form select,
    .servicemate-layout .mobile-search-form button {
        width: 100%;
        min-height: 44px;
    }
    
    /* Dashboard grid mobile optimization - only within Automate Geek */
    .servicemate-layout .dashboard-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .servicemate-layout .dashboard-card {
        background: white !important;
        border-radius: 0.75rem;
        padding: 0.75rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        min-height: 100px;
    }
    
    .servicemate-layout .dashboard-card-title {
        font-size: 0.75rem;
        color: #6b7280;
        margin-bottom: 0.25rem;
    }
    
    .servicemate-layout .dashboard-card-value {
        font-size: 1.5rem;
        font-weight: 700;
        /* Don't override colors - let Tailwind classes work */
    }
    
    /* Modal optimization for mobile */
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    /* Alert improvements */
    .alert {
        border-radius: 0.5rem;
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    /* Status badges mobile optimization */
    .status-badge {
        display: inline-flex;
        align-items: center;
        padding: 0.375rem 0.75rem;
        border-radius: 9999px;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    /* Priority indicators */
    .priority-high { border-left: 4px solid #ef4444; }
    .priority-medium { border-left: 4px solid #f59e0b; }
    .priority-low { border-left: 4px solid #10b981; }
}
