/* Petra Treasury - Main Stylesheet */

:root {
    --primary-color: #2E7D32;
    --secondary-color: #66BB6A;
    --accent-color: #A5D6A7;
    --dark-color: #1B5E20;
    --light-color: #E8F5E9;
    --text-color: #212121;
    --text-light: #757575;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --success-color: #28a745;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
    color: var(--text-color);
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-size: 17px;
    line-height: 1.47059;
    font-weight: 400;
    letter-spacing: -0.022em;
}

/* Typography - Apple Style */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.022em;
    margin-top: 0;
    margin-bottom: 0.8em;
}

h1 {
    font-size: 48px;
    line-height: 1.08349;
    font-weight: 700;
    letter-spacing: -0.003em;
}

h2 {
    font-size: 32px;
    line-height: 1.125;
    font-weight: 600;
    letter-spacing: -0.008em;
}

h3 {
    font-size: 24px;
    line-height: 1.16667;
    font-weight: 600;
    letter-spacing: -0.011em;
}

h4 {
    font-size: 20px;
    line-height: 1.2;
    font-weight: 600;
}

p {
    margin-bottom: 1em;
}

/* Header and Navigation */
.navbar {
    background-color: var(--primary-color);
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1000;
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.navbar-brand {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 1001;
}

.navbar-brand img {
    /* Height and width are set via inline styles from config */
    margin-right: 1rem;
    object-fit: contain;
    vertical-align: middle;
}

.brand-text {
    display: inline-block;
}

/* Hamburger Menu Button */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    position: relative;
    z-index: 1001;
}

.hamburger-line {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    margin: 5px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.navbar-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

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

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

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.navbar-menu li {
    margin: 0;
}

.navbar-menu a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.navbar-menu a:hover {
    opacity: 0.8;
}

.navbar-menu a.active {
    border-bottom: 2px solid white;
    padding-bottom: 2px;
}

/* Main Content */
/* Container is sized via inline styles from site_config to avoid hardcoding */
.container {
    flex: 1;
}

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

.card-header {
    background-color: var(--light-color);
    padding: 1rem;
    margin: -2rem -2rem 1rem -2rem;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid var(--primary-color);
}

.card-header h2 {
    color: var(--primary-color);
    margin: 0;
}

.version-meta {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--dark-color);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--primary-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

/* Alerts */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

/* Simple spacing utilities */
.mb-16 { margin-bottom: 1rem; }
.mb-24 { margin-bottom: 1.5rem; }
.mb-32 { margin-bottom: 2rem; }

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.table th {
    background-color: var(--light-color);
    color: var(--primary-color);
    font-weight: 600;
}

.table tr:hover {
    background-color: #f5f5f5;
}

@media (max-width: 768px) {
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    .table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
    }
}

/* Stock Analysis Specific */
.metrics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
    width: 100%;
}

.metric-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    transition: box-shadow 0.3s;
    flex: 1 1 0;
    min-width: 250px;
    max-width: calc(25% - 1.125rem);
}

@media (max-width: 768px) {
    .metric-card {
        min-width: 100%;
        max-width: 100%;
    }
}

.metric-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.metric-label {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.metric-value {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: bold;
}

/* Footer */
.footer {
    background-color: var(--dark-color);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
    width: 100%;
}

.footer a {
    color: var(--accent-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
    }
    
    .navbar-menu {
        margin-top: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .container {
        max-width: 95%;
        padding: 0 1rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .metric-card {
        padding: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .card-header {
        padding: 0.75rem;
        margin: -1rem -1rem 1rem -1rem;
    }

    .container {
        max-width: 100%;
        padding: 0 0.5rem;
        margin: 1rem auto;
    }

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

    .form-control {
        padding: 0.65rem;
        font-size: 16px;
        min-height: 44px;
    }
}
/* Enhanced Responsive Styles */
@media (max-width: 768px) {
    /* Navbar responsive */
    .navbar-container {
        padding: 0 1rem;
    }

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

    .navbar-brand img {
        /* Height controlled by config, only adjust margin */
        margin-right: 0.5rem;
    }

    .brand-text {
        font-size: 1rem;
    }

    .navbar-toggle {
        display: block;
    }

    .navbar-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--primary-color);
        flex-direction: column;
        padding: 1rem;
        gap: 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .navbar-menu.active {
        display: flex;
    }

    .navbar-menu li {
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .navbar-menu li:last-child {
        border-bottom: none;
    }

    .navbar-menu a {
        padding: 0.5rem;
        width: 100%;
    }

    .navbar-menu a.active {
        border-bottom: none;
        background-color: rgba(255,255,255,0.1);
        border-radius: 4px;
    }

    /* Form responsive */
    .form-row {
        flex-direction: column;
    }

    .col-md-6 {
        width: 100%;
    }

    /* Buttons responsive */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    /* Very small screens */
    .navbar-brand {
        font-size: 1rem;
    }

    .navbar-brand img {
        /* Height controlled by config */
        max-width: 100%;
    }

    .brand-text {
        display: none;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* Show only icons in nav on very small screens */
    @media (max-width: 360px) {
        .nav-text {
            display: none;
        }

        .navbar-menu a {
            justify-content: center;
        }
    }
}

/* iPad and tablet specific */
@media (min-width: 769px) and (max-width: 1024px) {
    .navbar-container {
        padding: 0 1.5rem;
    }

    .container {
        max-width: 95%;
    }

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

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
}

body {
    position: relative;
}

/* User Dropdown Styles */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-dropdown-toggle:hover::after {
    content: attr(data-username);
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    display: none;
    z-index: 1000;
    overflow: hidden;
    border: 1px solid rgba(46, 125, 50, 0.1);
}

.user-dropdown-menu.active {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: var(--light-color);
    color: var(--primary-color);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background-color: rgba(0, 0, 0, 0.1);
    margin: 4px 0;
}

.logout-item {
    color: var(--danger-color);
}

.logout-item:hover {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.logout-item i {
    color: var(--danger-color);
}

.login-button {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 50px;
    background-color: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.login-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Mobile responsive for user dropdown */
@media (max-width: 768px) {
    .navbar-right {
        position: absolute;
        right: 1rem;
        top: 1rem;
        z-index: 1002;
    }

    .user-dropdown {
        display: block;
    }

    .user-dropdown-toggle {
        display: flex;
    }

    .user-dropdown-menu {
        right: 0;
        background: white;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border: 1px solid rgba(46, 125, 50, 0.1);
    }

    .dropdown-item {
        color: var(--text-color);
        padding: 12px 16px;
    }

    .dropdown-item:hover {
        background-color: var(--light-color);
        color: var(--primary-color);
    }

    .dropdown-item i {
        color: var(--primary-color);
    }

    .dropdown-divider {
        background-color: rgba(0, 0, 0, 0.1);
    }

    .logout-item {
        color: var(--danger-color);
    }

    .logout-item:hover {
        background-color: rgba(220, 53, 69, 0.1);
        color: var(--danger-color);
    }

    .logout-item i {
        color: var(--danger-color);
    }

    .login-button {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

/* Navbar Layout Fix */
.navbar-left {
    display: flex;
    align-items: center;
    gap: 3rem;
    flex: 1;
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    margin-right: 0;
}

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

.navbar-right {
    margin-left: auto;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .navbar-container {
        flex-wrap: wrap;
        position: relative;
    }

    .navbar-left {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        width: 100%;
    }

    .navbar-toggle {
        order: 2;
        margin-left: auto;
        margin-right: 3rem;
    }

    .navbar-brand {
        order: 1;
    }

    .navbar-menu {
        order: 3;
        width: 100%;
        margin-top: 1rem;
    }

    .navbar-right {
        order: 4;
    }
}
