* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile-specific adjustments to fit two columns on small screens (iPhone) */
@media (max-width: 420px) {
    /* Make the stocks container use two columns */
    #stocks-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stock-card {
        padding: 0.8rem;
        min-height: 72px;
        gap: 0.25rem;
    }

    .stock-card .stock-symbol {
        font-size: 0.85rem;
    }

    .popup-summary-row { font-size: 0.8rem; }
    .popup-summary-label { font-size: 0.75rem; }
    .popup-summary-value { font-size: 0.85rem; }

    .stock-header { padding: 4px 8px; }
    .company-name { font-size: 0.82rem; }
}

html {
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    overflow-x: hidden;
    width: 100%;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

header h1 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 2rem;
}

nav ul {
    display: flex;
    justify-content: center;
    list-style: none;
    gap: 2rem;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: rgba(255,255,255,0.2);
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

section {
    background: white;
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
    color: #667eea;
    margin-bottom: 1rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

h3 {
    color: #764ba2;
    margin-bottom: 1rem;
}

.reports-list {
    min-height: 200px;
}

#reports-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.report-card {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.report-card h4 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.report-card p {
    color: #666;
    font-size: 0.9rem;
}

footer {
    text-align: center;
    padding: 2rem;
    background: #333;
    color: white;
    margin-top: 3rem;
}

/* Utility classes */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* Sectors Section */
.sectors {
    margin-bottom: 2rem;
}

.sectors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.sector-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.sector-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.sector-card:hover::before {
    opacity: 0.1;
}

.sector-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.sector-card > * {
    position: relative;
    z-index: 1;
}

.sector-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.sector-card h4 {
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.sector-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    min-height: 2.5rem;
}

.sector-count {
    color: #667eea;
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(102, 126, 234, 0.2);
}

/* Stock cards (used on sector-detail page) - styled to match sector boxes on index */
/* Make stock cards match sector cards exactly */
.stock-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 96px;
}

.stock-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.stock-card:hover::before {
    opacity: 0.06;
}

.stock-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.stock-card > * { position: relative; z-index: 1; }

.stock-card .stock-symbol {
    font-weight: 700;
    color: #0f172a;
    display: inline-block;
    background: transparent;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.95rem;
}

.stock-header { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.position-label { margin-left: auto; }
.side-badge.flat { background: transparent; color: #666; border-color: transparent; }
.company-name { text-align:left; }

/* Make the stock card header visually match the popup header (gradient background) */
.stock-header {
    padding: 6px 10px;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

.stock-header .stock-symbol {
    color: #ffffff;
    background: transparent;
}

.stock-header .position-label .side-badge.flat {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-color: rgba(255,255,255,0.15);
}

/* Popup header to match same styling */
.popup-header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:8px;
    padding: 8px 12px;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 600;
}

/* Unified badge style for all stocks */
.side-badge, .popup-count {
    display:inline-block;
    padding:3px 8px;
    border-radius:6px;
    font-size:0.82rem;
    color: #ffffff;
    border: 1px solid transparent;
}

/* Variants for long/short */
.side-badge.long, .popup-count.long { background: #10b981; border-color: rgba(16,185,129,0.15); }
.side-badge.short, .popup-count.short { background: #ef4444; border-color: rgba(239,68,68,0.15); }

/* Popup-summary styles reused inside each stock card */
.popup-summary { display:flex; flex-direction:column; gap:6px; }
.popup-summary-row { display:flex; justify-content:space-between; gap:8px; font-size:0.9rem; color:#444; }
.popup-summary-label { color:#666; font-size:0.85rem; }
.popup-summary-value.positive { color:#059669; font-weight:600; }
.popup-summary-value.negative { color:#ef4444; font-weight:600; }
.card-summary { padding:6px 0; }
.popup-trade-count { font-size:0.85rem; color:#666; }

/* Breadcrumb styles */
.breadcrumb {
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #666;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* ============================================
   MOBILE RESPONSIVE STYLES - IPHONE COMPATIBLE
   ============================================ */

/* Tablets and medium screens */
@media (max-width: 1024px) {
    main {
        padding: 0 1rem;
        margin: 1.5rem auto;
    }

    .sectors-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    #reports-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* Mobile devices (iPhone and similar) */
@media (max-width: 768px) {
    /* Header adjustments */
    header {
        padding: 1rem 0.5rem;
    }

    header h1 {
        font-size: 1.4rem;
        margin-bottom: 0.75rem;
        padding: 0 0.5rem;
    }

    /* Navigation - stack on mobile */
    nav ul {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
        padding: 0 0.5rem;
    }

    nav a {
        padding: 0.6rem 1.2rem;
        display: block;
        width: 100%;
        max-width: 250px;
        text-align: center;
        /* Larger touch targets */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Main content */
    main {
        padding: 0 0.5rem;
        margin: 1rem auto;
    }

    section {
        padding: 1.25rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* Breadcrumb */
    .breadcrumb {
        padding: 0.6rem 0.75rem;
        margin-bottom: 1rem;
        font-size: 0.85rem;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Sectors grid - 2 columns on mobile */
    .sectors-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .sector-card {
        padding: 1rem;
    }

    .sector-icon {
        font-size: 2rem;
    }

    .sector-card h4 {
        font-size: 1rem;
    }

    .sector-description {
        font-size: 0.85rem;
        min-height: 2rem;
    }

    /* Reports grid - single column on mobile */
    #reports-container {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .report-card {
        padding: 1rem;
    }

    /* Footer */
    footer {
        padding: 1.5rem 1rem;
        margin-top: 2rem;
        font-size: 0.9rem;
    }
}

/* Extra small devices (iPhone SE, small phones) */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.2rem;
    }

    nav ul {
        gap: 0.4rem;
    }

    nav a {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* Sectors grid - single column for very small screens */
    .sectors-grid {
        grid-template-columns: 1fr;
    }

    .sector-card {
        padding: 1rem 0.75rem;
    }

    section {
        padding: 1rem;
    }

    h2 {
        font-size: 1.2rem;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    header h1 {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }

    nav ul {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    nav a {
        max-width: 150px;
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    .sectors-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS Safari */
    body {
        -webkit-text-size-adjust: 100%;
    }

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

    /* Prevent input zoom on iOS */
    input, select, textarea {
        font-size: 16px;
    }
}
