/* AIRA Professional Dashboard CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #f8fafc;
    color: #1e293b;
    line-height: 1.5;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header-subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* User Profile Styles */
.user-profile {
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.logout-link {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.logout-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Responsive KPI Bar */
.kpi-bar {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.kpi-item {
    text-align: center;
    min-width: 120px;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

@media (max-width: 768px) {
    .kpi-bar {
        gap: 1.5rem;
        padding: 1rem;
        justify-content: space-around;
    }
    
    .kpi-item {
        min-width: 80px;
    }
    
    .kpi-value {
        font-size: 1.25rem;
    }
    
    .kpi-label {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .kpi-bar {
        gap: 1rem;
        padding: 0.75rem 0.5rem;
    }
    
    .kpi-item {
        min-width: 70px;
    }
    
    .kpi-value {
        font-size: 1.1rem;
    }
    
    .kpi-label {
        font-size: 0.75rem;
    }
}

/* Responsive Navigation Tabs */
.nav-tabs {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
    padding: 0 2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.nav-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.nav-tab {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0; /* Prevent tabs from shrinking */
    white-space: nowrap;
    min-width: 120px;
}

.nav-tab:hover {
    color: #1e40af;
    background: #f1f5f9;
}

.nav-tab.active {
    color: #1e40af;
    border-bottom-color: #1e40af;
    background: #f8fafc;
}

.nav-tab.disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}

.nav-tab.disabled .spinner-small {
    opacity: 1;
    border-color: #e5e7eb;
    border-top-color: #3b82f6;
}

.nav-tab.disabled:hover {
    background: #f8fafc;
    color: #94a3b8;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Status Messages */
.status-message {
    margin-bottom: 1rem;
}

.status-success {
    background: #dcfce7;
    color: #166534;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid #16a34a;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid #dc2626;
}

/* Buttons */
.btn {
    background: #1e40af;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
}

.btn-secondary {
    background: #6b7280;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-primary {
    background: #1e40af;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

.card-content {
    padding: 1.5rem;
}

/* Responsive Tables */
.table-container {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Prevent table from becoming too narrow */
}

@media (max-width: 768px) {
    .table {
        min-width: 800px; /* Force horizontal scroll on mobile for better readability */
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .table th {
        position: sticky;
        top: 0;
        z-index: 10;
        background: #f8fafc;
    }
}

.table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
}

.table tr:hover {
    background: #f8fafc;
}

/* Responsive Charts */
.chart-container {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    min-height: 250px;
    position: relative;
}

@media (max-width: 768px) {
    .chart-container {
        padding: 1rem;
        min-height: 200px;
    }
    
    .chart-container canvas {
        max-height: 250px !important;
    }
}

@media (max-width: 480px) {
    .chart-container {
        padding: 0.75rem;
        min-height: 180px;
    }
    
    .chart-container canvas {
        max-height: 200px !important;
    }
}
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* Enhanced responsive grid behavior */
@media (max-width: 1200px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

@media (max-width: 480px) {
    .grid-2,
    .grid-3 {
        gap: 0.75rem;
    }
}

/* MEDDIC Dashboard Responsive Design - Mobile First */
.meddic-metrics-grid {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Mobile first - single column */
    gap: 0.5rem !important;
    margin-bottom: 1.5rem !important;
}

/* Progressive Enhancement for Larger Screens */
@media (min-width: 481px) {
    .meddic-metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
}

@media (min-width: 769px) {
    .meddic-metrics-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }
}

@media (min-width: 993px) {
    .meddic-metrics-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 1rem !important;
    }
}

@media (min-width: 1201px) {
    .meddic-metrics-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 1rem !important;
        margin-bottom: 2rem !important;
    }
}

/* Base metric tile styles */
.metric-tile {
    background: white !important;
    padding: 1.5rem !important;
    border-radius: 0.75rem !important;
    text-align: center !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
    min-height: 100px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

.meddic-criteria {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1rem !important;
}

.deals-by-quarter {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 2rem !important;
}

.tab-title-section {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 1rem !important;
}

/* Additional mobile-specific MEDDIC responsive rules */
@media (max-width: 768px) {
    .meddic-criteria {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    .tab-title-section {
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
    }
    
    .tab-title-section h2 {
        font-size: 1.5rem !important;
    }
    
    .deals-by-quarter {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .deal-details {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    .meddic-breakdown-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .deal-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
    
    .deal-metrics {
        text-align: left !important;
        min-width: auto !important;
    }
}

@media (max-width: 480px) {
    .metric-tile {
        padding: 1rem !important;
        min-height: 80px !important;
    }
    
    .metric-tile .metric-label {
        font-size: 0.8rem !important;
    }
    
    .metric-tile .metric-value {
        font-size: 1.25rem !important;
    }
    
    .meddic-explanation {
        margin: 0 -0.75rem 1.5rem -0.75rem !important;
        border-radius: 0 !important;
        padding: 1rem !important;
    }
    
    .tab-title-section {
        margin: 0 -0.75rem 1rem -0.75rem !important;
        padding: 1rem 0.75rem !important;
        background: #f8fafc !important;
        border-radius: 0 !important;
    }
    
    .tab-title-section button {
        width: 100% !important;
        text-align: center !important;
    }
    
    .deal-details {
        font-size: 0.7rem !important;
    }
    
    .meddic-breakdown {
        font-size: 0.65rem !important;
    }
    
    .meddic-breakdown-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
}

/* Additional MEDDIC Dashboard Styles */
.meddic-methodology-section {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 1rem !important;
}

.deal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    margin-bottom: 0.5rem !important;
}

.deal-info {
    flex: 1 !important;
}

.deal-details {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.75rem !important;
    font-size: 0.75rem !important;
    color: #64748b !important;
    margin-bottom: 0.75rem !important;
}

.meddic-breakdown-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.5rem !important;
}

.meddic-breakdown-bottom {
    margin-top: 0.25rem !important;
}

/* Responsive Typography */
@media (max-width: 768px) {
    .card-title {
        font-size: 1rem;
    }
    
    .metric-card .metric-value {
        font-size: 1.5rem;
    }
    
    .metric-card .metric-label {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .card-title {
        font-size: 0.95rem;
    }
    
    .metric-card .metric-value {
        font-size: 1.25rem;
    }
    
    .metric-card .metric-label {
        font-size: 0.75rem;
    }
    
    body {
        font-size: 0.9rem;
    }
}

/* Pipeline Metrics Grid - Mobile First Responsive Design */
.pipeline-metrics-grid {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Mobile first - single column */
    gap: 0.5rem !important;
    margin-bottom: 1.5rem !important;
}

/* Progressive Enhancement for Pipeline Grid */
@media (min-width: 481px) {
    .pipeline-metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
}

@media (min-width: 769px) {
    .pipeline-metrics-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }
}

@media (min-width: 993px) {
    .pipeline-metrics-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 1rem !important;
    }
}

@media (min-width: 1201px) {
    .pipeline-metrics-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 1rem !important;
        margin-bottom: 2rem !important;
    }
}

.metric-tile {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    text-align: center;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pipeline-metrics-grid .metric-label {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.pipeline-metrics-grid .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* Pipeline-specific mobile responsive styles */
@media (max-width: 768px) {
    .pipeline-metrics-grid .metric-value {
        font-size: 1.25rem !important;
    }
    
    .metric-tile {
        padding: 1rem !important;
        min-height: 80px !important;
    }
}

@media (max-width: 480px) {
    .pipeline-metrics-grid .metric-value {
        font-size: 1.1rem !important;
    }
    
    .pipeline-metrics-grid .metric-label {
        font-size: 0.8rem !important;
    }
}

.metric-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    text-align: center;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Legacy metric styles for other components */
.metric-card .metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.metric-card .metric-label {
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Iframe */
.iframe-container {
    background: white;
    border-radius: 0.75rem;
    padding: 0;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: 600px;
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Responsive Filter Controls */
.filter-controls {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
}

.pms-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .filter-controls {
        margin: 0 -1rem 1.5rem -1rem;
        padding: 1rem;
        border-radius: 0;
    }
    
    .pms-filter-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.5rem;
    }
    
    .pms-filter-item {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .pms-filter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .filter-controls h4 {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
}

/* Responsive Form Controls */
select, input[type="text"], input[type="email"] {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    font-size: 0.875rem;
    width: 100%;
    max-width: 300px;
}

@media (max-width: 768px) {
    select, input[type="text"], input[type="email"] {
        max-width: none;
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem; /* Better touch targets */
    }
}

/* Enhanced Responsive Design */

/* Mobile-first approach with better breakpoints */
@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .header-actions .btn {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .user-profile {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        padding-top: 1rem;
        width: 100%;
    }
    
    .header-title {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 1rem 0.75rem;
    }
    
    .nav-tabs {
        flex-wrap: wrap;
        gap: 0.25rem;
        padding: 0 0.75rem;
    }
    
    .nav-tab {
        min-width: calc(50% - 0.125rem);
        flex: 1;
        text-align: center;
        font-size: 0.8rem;
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 0 1.5rem;
    }
    
    .header-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }
    
    .header-actions .btn {
        flex: 1;
        min-width: 140px;
    }
    
    .kpi-bar {
        flex-direction: column;
        gap: 1rem;
        padding: 1.5rem;
    }
    
    .nav-tabs {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.5rem;
        padding: 0 1rem;
    }
    
    .nav-tab {
        min-width: 120px;
        flex: 1 1 auto;
    }
    
    .main-content {
        padding: 1.5rem 1rem;
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
}

@media (max-width: 1024px) {
    .header-actions {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .main-content {
        padding: 1.5rem;
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Loading States */
.htmx-indicator {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

.htmx-request.htmx-indicator {
    opacity: 1;
}

/* Ensure proper spacing */
.main-content > *:last-child {
    margin-bottom: 0;
}

#tab-content {
    min-height: 400px;
}

/* Loading Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Professional scrollbars */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Success button styling for Campaign App launch */
.btn-success {
    background: #10b981;
    color: white;
    border: 2px solid #10b981;
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.25);
}

/* Header logo and layout improvements */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    height: 50px;
    width: auto;
    border-radius: 4px;
}

.header-text {
    display: flex;
    flex-direction: column;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-left {
        justify-content: center;
    }
    
    .header-logo {
        height: 40px;
    }
}
