/* Comprehensive Mobile Responsive Styles */

/* Base Mobile Adjustments */
@media (max-width: 1024px) {
    /* Typography scaling */
    html {
        font-size: 14px;
    }
    
    /* Container adjustments */
    .container,
    .main-content,
    .page-content {
        padding: 1rem;
        max-width: 100%;
    }
    
    /* Grid adjustments */
    .stats-grid,
    .portfolio-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Card adjustments */
    .premium-card,
    .investment-card,
    .stock-card {
        padding: 1.25rem;
    }
}

/* Tablet Portrait */
@media (max-width: 768px) {
    /* Header adjustments */
    .main-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-title {
        font-size: 1.5rem;
    }
    
    /* Stats grid - single column */
    .stats-grid,
    .portfolio-stats {
        grid-template-columns: 1fr;
    }
    
    /* Charts */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chart-card {
        padding: 1rem;
    }
    
    .chart-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .chart-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    /* Tables to cards transformation */
    .investment-table {
        display: block;
    }
    
    .investment-table thead {
        display: none;
    }
    
    .investment-table tbody {
        display: block;
    }
    
    .investment-table tr {
        display: block;
        margin-bottom: 1rem;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        padding: 1rem;
    }
    
    .investment-table td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }
    
    .investment-table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: rgba(255, 255, 255, 0.6);
        font-size: 0.875rem;
    }
    
    /* Forms */
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    input, select, textarea {
        width: 100%;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn, button {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Stock cards specific */
    .stocks-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stock-card {
        padding: 1rem;
    }
    
    .stock-price-section {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .holdings-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        text-align: left;
    }
    
    .holdings-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .holdings-item:last-child {
        border-bottom: none;
    }
    
    /* Portfolio overview card */
    .portfolio-overview-card {
        padding: 1.5rem 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Modal adjustments */
    .stock-details-content,
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 1rem;
        max-height: 90vh;
        padding: 1.5rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    /* Navigation */
    .nav-badge {
        display: none;
    }
    
    .nav-item {
        padding: 1rem 1.5rem;
    }
    
    /* Investment sections */
    .investment-header-section {
        padding: 1.5rem 1rem;
        text-align: center;
    }
    
    .investment-title {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    .title-subtitle {
        display: block;
        margin-top: 0.5rem;
        font-size: 1rem;
    }
    
    /* Performance bar */
    .performance-bar {
        height: 12px;
        margin-bottom: 1rem;
    }
    
    .performance-indicator {
        width: 20px;
        height: 20px;
    }
}

/* Mobile Portrait */
@media (max-width: 480px) {
    /* Base font size */
    html {
        font-size: 13px;
    }
    
    /* Spacing */
    .container,
    .main-content {
        padding: 0.75rem;
    }
    
    /* Headers */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    
    /* Cards */
    .premium-card,
    .stock-card {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .card-header {
        margin-bottom: 0.75rem;
    }
    
    .card-icon {
        width: 40px;
        height: 40px;
    }
    
    .card-value {
        font-size: 1.25rem;
    }
    
    /* Stock cards mobile */
    .stock-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .stock-status {
        align-self: flex-end;
        margin-top: -2rem;
    }
    
    .stock-name {
        font-size: 1rem;
    }
    
    .stock-meta {
        font-size: 0.75rem;
        gap: 0.5rem;
    }
    
    .price-value {
        font-size: 1.25rem;
    }
    
    /* Action buttons */
    .stock-actions {
        margin-top: 0.5rem;
    }
    
    .stock-action-btn {
        padding: 0.625rem;
        font-size: 0.875rem;
    }
    
    /* Forms */
    label {
        font-size: 0.875rem;
    }
    
    input, select, textarea {
        padding: 0.75rem;
        font-size: 16px;
    }
    
    /* Modals */
    .modal-header {
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .detail-section {
        margin-bottom: 1rem;
    }
    
    .detail-section-title {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .detail-item {
        padding: 0.75rem;
    }
    
    /* Dashboard specific */
    .dashboard-item {
        padding: 0.75rem;
    }
    
    /* Portfolio list */
    .portfolio-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1rem 0;
    }
    
    .portfolio-info {
        width: 100%;
    }
    
    .portfolio-value {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .portfolio-amount {
        font-size: 1rem;
    }
    
    /* Activities */
    .activity-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .activity-icon {
        width: 36px;
        height: 36px;
    }
    
    .activity-description {
        font-size: 0.875rem;
    }
    
    .activity-date {
        font-size: 0.75rem;
    }
    
    /* Charts on mobile */
    .chart-wrapper {
        height: 250px !important;
    }
    
    /* Refresh indicator */
    .refresh-indicator {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        font-size: 0.75rem;
        text-align: center;
    }
    
    /* Empty states */
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state-icon {
        font-size: 3rem;
    }
    
    .empty-state-text {
        font-size: 0.875rem;
    }
}

/* Small phones */
@media (max-width: 375px) {
    /* Container padding */
    .container,
    .main-content {
        padding: 0.5rem;
    }
    
    /* Typography */
    .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    /* Cards */
    .premium-card,
    .stock-card {
        padding: 0.875rem;
    }
    
    /* Stock specific */
    .stock-name {
        font-size: 0.9375rem;
    }
    
    .price-box {
        padding: 0.75rem;
    }
    
    .price-value {
        font-size: 1.125rem;
    }
    
    /* Holdings */
    .holdings-value {
        font-size: 1rem;
    }
    
    /* Buttons */
    .stock-action-btn {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }
    
    /* Modal */
    .stock-details-content {
        padding: 1.25rem;
    }
}

/* Landscape specific adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    /* Reduce vertical spacing */
    .main-header {
        padding: 0.5rem 1rem;
    }
    
    .investment-header-section {
        padding: 1rem;
    }
    
    .portfolio-overview-card {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
    }
    
    .premium-card {
        padding: 0.75rem;
    }
    
    .card-content h3 {
        font-size: 0.875rem;
    }
    
    .card-value {
        font-size: 1.125rem;
    }
    
    /* Hide decorative elements */
    .portfolio-overview-card::before,
    .starfield {
        display: none;
    }
    
    /* Compact stock cards */
    .stocks-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stock-card {
        padding: 0.75rem;
    }
    
    /* Chart height */
    .chart-wrapper {
        height: 200px !important;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) {
    /* Remove hover effects */
    .stock-card:hover,
    .premium-card:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Add tap highlight */
    .stock-action-btn,
    .nav-item,
    button,
    a {
        -webkit-tap-highlight-color: rgba(200, 155, 66, 0.2);
    }
    
    /* Active states */
    .stock-action-btn:active,
    button:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Prevent bounce scrolling */
    .modal-content,
    .stock-details-content {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
    
    /* Fix input zoom */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Safe area padding */
    .main-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Android specific */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Fix font rendering */
    body {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: subpixel-antialiased;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .stock-card,
    .premium-card {
        border: 2px solid;
    }
    
    .price-change.positive {
        color: #00ff00;
    }
    
    .price-change.negative {
        color: #ff0000;
    }
}

/* Print styles */
@media print {
    .mobile-menu-toggle,
    .sidebar,
    .stock-actions,
    .chart-controls,
    .refresh-indicator {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    .stock-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Force smooth scrolling */
@media (max-width: 1024px) {
    html {
        scroll-behavior: smooth;
    }
    
    * {
        -webkit-overflow-scrolling: touch;
    }
}