/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    color: #667eea;
    margin-bottom: 10px;
    text-align: center;
}

.login-box h2 {
    color: #666;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 400;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #fcc;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 12px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
    margin-right: 5px;
}

.btn-link {
    background: none;
    color: #667eea;
    text-decoration: underline;
    padding: 4px 8px;
}

.btn-link:hover {
    color: #5568d3;
    transform: none;
    box-shadow: none;
}

/* Dashboard */
.dashboard-container {
    min-height: 100vh;
    background: #f5f7fa;
}

.dashboard-header {
    background: white;
    padding: 20px 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1 {
    color: #667eea;
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: #666;
}

.dashboard-main {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.alerts-section {
    background: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.section-header h2 {
    color: #333;
    font-size: 24px;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.filter-group label {
    font-size: 15px;
    color: #333;
    font-weight: 600;
    white-space: nowrap;
}

.filter-group select {
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 500;
    min-width: 140px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-group select:hover {
    border-color: #5568d3;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Message */
.message {
    padding: 12px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Table */
.alerts-table-container {
    overflow-x: auto;
}

.alerts-table {
    width: 100%;
    border-collapse: collapse;
}

.alerts-table thead {
    background: #f8f9fa;
}

.alerts-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #dee2e6;
}

.alerts-table td {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
}

.alerts-table tbody tr:hover {
    background: #f8f9fa;
}

.alerts-table tbody tr[data-status="0"] {
    background: #f8f9fa;
    color: #6c757d;
}

.alerts-table tbody tr[data-status="0"]:hover {
    background: #e9ecef;
}

.no-alerts {
    text-align: center;
    color: #999;
    padding: 40px !important;
}

.loading-msg {
    font-style: italic;
}

/* Stocks cell: chips and "N stocks" + Manage */
.stocks-cell {
    max-width: 320px;
}

.stocks-cell .stock-chip,
.stock-chip {
    display: inline-block;
    padding: 4px 10px;
    margin: 2px 4px 2px 0;
    background: #e8ecf7;
    color: #333;
    border-radius: 6px;
    font-size: 13px;
}

.stock-chip.removable {
    padding-right: 28px;
    position: relative;
}

.chip-remove {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
}

.chip-remove:hover {
    color: #dc3545;
}

.stocks-summary {
    margin-right: 8px;
    color: #555;
    font-size: 14px;
}

.stocks-cell .manage-stocks-btn {
    margin-left: 4px;
}

.stocks-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px 0;
}

.manage-stocks-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.manage-stocks-toolbar input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.manage-stocks-toolbar input:focus {
    outline: none;
    border-color: #667eea;
}

.modal-content-wide {
    max-width: 560px;
}

/* Status Badge */
.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #333;
    font-size: 20px;
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-actions .btn {
    width: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .header-left {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .header-actions {
        width: 100%;
    }

    .filter-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .filter-group select {
        width: 100%;
        min-width: 0;
    }

    .dashboard-main {
        padding: 20px;
    }

    .alerts-table {
        font-size: 14px;
        display: block;
    }

    .alerts-table thead {
        display: none;
    }

    .alerts-table tbody tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        padding: 12px;
        background: #fff;
    }

    .alerts-table tbody tr:hover {
        background: #f8f9fa;
    }

    .alerts-table td {
        display: block;
        padding: 8px 0;
        border-bottom: none;
    }

    .alerts-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #555;
        display: block;
        margin-bottom: 4px;
        font-size: 12px;
    }

    .alerts-table td.stocks-cell::before {
        content: "Stock(s)";
    }

    .alerts-table td:nth-child(2)::before {
        content: "Alert type";
    }

    .alerts-table td:nth-child(3)::before {
        content: "Status";
    }

    .alerts-table td:nth-child(4)::before {
        content: "Actions";
    }

    .alerts-table td.no-alerts {
        padding: 40px 20px;
    }

    .alerts-table td.no-alerts::before {
        display: none;
    }

    .stocks-cell {
        max-width: none;
    }
}
