/**
 * common.css - Shared styles for WBH Study Dashboard
 * Used by: index.html, po-editor.html
 */

/* Reset and Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden;
    overscroll-behavior: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding: 15px;
    line-height: 1.4;
}

h1 {
    text-align: center;
    margin-bottom: 10px;
    color: #333;
    font-size: 1.5em;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 0.9em;
}

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

.card h2 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #333;
}

.card h3 {
    font-size: 0.95em;
    margin-bottom: 8px;
    color: #555;
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33,150,243,0.2);
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.form-row label {
    font-size: 0.85em;
    color: #666;
    min-width: 80px;
}

.form-row input,
.form-row select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
}

.form-row input[type="text"] {
    flex: 1;
    min-width: 150px;
}

.form-row input[type="number"] {
    width: 80px;
}

.form-row input[type="color"] {
    width: 50px;
    height: 36px;
    padding: 2px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-primary:hover {
    background: #1976d2;
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #388e3c;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-secondary {
    background: #757575;
    color: white;
}

.btn-secondary:hover {
    background: #616161;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8em;
}

.btn-outline {
    background: transparent;
    color: #2196f3;
    border: 1px solid #2196f3;
}

.btn-outline:hover {
    background: #e3f2fd;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.top-bar-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.top-bar-right {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 90%;
}

.modal h2 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.modal p {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 20px;
    text-align: center;
}

/* Messages */
.message {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.message.error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.message.info {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

.error-message {
    color: #f44336;
    font-size: 0.9em;
    margin-top: 10px;
    text-align: center;
    display: none;
}

.error-message.show {
    display: block;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner,
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #2196f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading .spinner {
    width: 30px;
    height: 30px;
    border-width: 3px;
}

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

/* Action Bar */
.action-bar {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.action-bar .btn {
    flex: 1;
    min-width: 120px;
}

/* Links */
.back-link {
    color: #2196f3;
    text-decoration: none;
    font-size: 0.9em;
}

.back-link:hover {
    text-decoration: underline;
}
