/* ===== BROKER INTEGRATIONS STYLES ===== */

.broker-integrations-container {
    max-width: 1400px;
    margin: 40px auto;
    font-family: var(--font-primary);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.1);
    overflow: hidden;
}

.integrations-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

.integrations-header h3 {
    font-size: 2.5em;
    font-weight: 300;
    margin: 0 0 15px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.integrations-header p {
    font-size: 1.1em;
    margin: 0;
    opacity: 0.9;
}

/* ===== BROKER GRID ===== */
.broker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    padding: 40px;
}

.broker-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.broker-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.broker-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.broker-card:hover::before {
    opacity: 1;
}

/* ===== BROKER HEADER ===== */
.broker-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.broker-logo {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.broker-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.broker-icon {
    font-size: 2em;
    opacity: 0.7;
}

.broker-info {
    flex: 1;
}

.broker-info h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.4em;
    font-weight: 600;
}

.broker-type {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.broker-status {
    display: flex;
    align-items: center;
}

.status-indicator {
    font-size: 1.5em;
    padding: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.8);
}

.status-indicator.active {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
}

.status-indicator.inactive {
    background: rgba(158, 158, 158, 0.1);
    color: #9E9E9E;
}

/* ===== BROKER FEATURES ===== */
.broker-features {
    padding: 20px 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.feature-tag {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: 500;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

/* ===== BROKER ACTIONS ===== */
.broker-actions {
    padding: 20px 25px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.broker-loading {
    margin-left: auto;
}

.broker-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    min-height: 45px;
}

.broker-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.broker-btn:active {
    transform: translateY(0);
}

.broker-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.broker-btn.setup-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.broker-btn.setup-btn:hover {
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
}

.broker-btn.sync-btn {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
}

.broker-btn.sync-btn:hover {
    box-shadow: 0 8px 25px rgba(23, 162, 184, 0.4);
}

.broker-btn.settings-btn {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.broker-btn.settings-btn:hover {
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
}

/* ===== BROKER MODAL ===== */
.broker-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    background: white;
    margin: 5% auto;
    max-width: 600px;
    width: 90%;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideInUp 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 40px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 300;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 40px;
}

/* ===== BROKER CONNECTION FORM ===== */
#broker-connection-form {
    display: grid;
    gap: 30px;
}

.form-section {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 30px;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h4 {
    color: #333;
    font-size: 1.3em;
    margin: 0 0 20px 0;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
    display: inline-block;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: white;
    min-height: 50px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[type="password"] {
    font-family: monospace;
    letter-spacing: 1px;
}

/* ===== FORM ACTIONS ===== */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

.test-connection {
    background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.test-connection:hover {
    box-shadow: 0 8px 25px rgba(255, 193, 7, 0.4);
}

/* ===== BROKER SETTINGS ===== */
.broker-settings {
    display: grid;
    gap: 30px;
}

.setting-group {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 30px;
}

.setting-group:last-child {
    border-bottom: none;
}

.setting-group h4 {
    color: #333;
    font-size: 1.2em;
    margin: 0 0 20px 0;
    font-weight: 600;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: #555;
    gap: 10px;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

/* ===== SYNC STATUS ===== */
.sync-status {
    margin: 20px 40px;
    padding: 20px;
    border-radius: 10px;
    font-weight: 500;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sync-status.success {
    background: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.sync-status.error {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
    border: 1px solid rgba(244, 67, 54, 0.2);
}

.sync-results {
    width: 100%;
}

.sync-results h4 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.3em;
}

.sync-account,
.sync-trades,
.sync-time {
    margin-bottom: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.5);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.sync-account h5 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.1em;
}

.sync-account p {
    margin: 5px 0;
    color: #666;
}

.sync-trades {
    background: rgba(76, 175, 80, 0.1);
    border-left-color: #4CAF50;
    color: #2e7d32;
    font-size: 16px;
    font-weight: 600;
}

.sync-time {
    background: rgba(158, 158, 158, 0.1);
    border-left-color: #9E9E9E;
    color: #666;
    font-size: 14px;
}

/* ===== BROKER MESSAGE ===== */
.broker-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
}

.broker-message.success {
    background: #28a745;
    color: white;
}

.broker-message.error {
    background: #dc3545;
    color: white;
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s ease-in-out infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .broker-integrations-container {
        margin: 20px 10px;
        border-radius: 15px;
    }

    .integrations-header {
        padding: 30px 20px;
    }

    .integrations-header h3 {
        font-size: 2em;
    }

    .broker-grid {
        grid-template-columns: 1fr;
        padding: 30px 20px;
        gap: 20px;
    }

    .broker-header {
        padding: 20px;
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .broker-logo {
        width: 50px;
        height: 50px;
    }

    .broker-info h4 {
        font-size: 1.2em;
    }

    .broker-features {
        padding: 15px 20px;
        justify-content: center;
    }

    .broker-actions {
        padding: 15px 20px;
        flex-direction: column;
    }

    .broker-btn {
        width: 100%;
        min-height: 50px;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .sync-results h4 {
        font-size: 1.1em;
    }
}

@media (max-width: 480px) {
    .integrations-header {
        padding: 20px 15px;
    }

    .integrations-header h3 {
        font-size: 1.5em;
    }

    .broker-grid {
        padding: 20px 15px;
    }

    .broker-card {
        border-radius: 10px;
    }

    .broker-header {
        padding: 15px;
    }

    .broker-logo {
        width: 40px;
        height: 40px;
    }

    .broker-icon {
        font-size: 1.5em;
    }

    .broker-info h4 {
        font-size: 1.1em;
    }

    .broker-features {
        padding: 10px 15px;
    }

    .broker-actions {
        padding: 10px 15px;
    }

    .modal-header h3 {
        font-size: 1.3em;
    }

    .form-section h4 {
        font-size: 1.1em;
    }

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

/* ===== DARK MODE SUPPORT ===== */
[data-theme="dark"] .broker-card {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .broker-header {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .broker-features {
    background: rgba(255,255,255,0.02);
}

[data-theme="dark"] .broker-actions {
    border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .feature-tag {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.3);
    color: #e9ecef;
}

[data-theme="dark"] .modal-content {
    background: rgba(255,255,255,0.05);
    color: #e9ecef;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #e9ecef;
}

[data-theme="dark"] .sync-account,
[data-theme="dark"] .sync-trades,
[data-theme="dark"] .sync-time {
    background: rgba(255,255,255,0.05);
    color: #e9ecef;
}

/* ===== BROKER AUTH ERROR ===== */
.broker-auth-error {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    margin: 40px auto;
    max-width: 500px;
    border: 1px solid #dee2e6;
}

.broker-auth-error p {
    margin: 0;
    color: #6c757d;
    font-size: 16px;
}