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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    line-height: 1.6;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #8B0000 0%, #B22222 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.title-container {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.version-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.credits {
    font-size: 0.85rem;
    opacity: 0.9;
}

.credits a:hover {
    text-decoration: underline !important;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: white;
    color: #8B0000;
}

.btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid white;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

/* Main Layout */
.app-container {
    display: flex;
    height: calc(100vh - 80px);
    overflow: hidden;
}

/* Parameter Panel */
.parameter-panel {
    width: 280px;
    background: white;
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid #e0e0e0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

.param-section {
    margin-bottom: 1.5rem;
}

.param-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.param-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.param-control input[type="number"] {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
}

.param-control input[type="number"]:focus {
    outline: none;
    border-color: #8B0000;
}

.param-control .unit {
    font-size: 0.85rem;
    color: #777;
    min-width: 30px;
}

.param-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.param-select:focus {
    outline: none;
    border-color: #8B0000;
}

.calculated-bpm {
    margin-top: 0.5rem;
    padding: 0.4rem;
    background: #f9f9f9;
    border-radius: 4px;
    text-align: center;
}

.calculated-bpm small {
    color: #666;
    font-weight: 500;
}

/* Template Section */
.template-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e0e0e0;
}

.template-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
}

.template-btn {
    width: 100%;
    padding: 0.7rem;
    margin-bottom: 0.5rem;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-btn:hover {
    background: #8B0000;
    color: white;
    border-color: #8B0000;
}

/* ECG Canvas Container */
.ecg-canvas-container {
    flex: 1;
    padding: 2rem;
    overflow: auto;
    background: #fafafa;
}

#ecg-canvas {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    padding: 1.5rem;
    min-height: 800px;
}

/* ECG Grid Styling */
.ecg-lead-container {
    margin-bottom: 1rem;
}

.lead-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #8B0000;
    margin-bottom: 0.3rem;
}

.grid-line {
    shape-rendering: crispEdges;
}

.major-grid {
    stroke: #f0a0a0;
    stroke-width: 1px;
    shape-rendering: crispEdges;
}

.minor-grid {
    stroke: #fce0e0;
    stroke-width: 0.5px;
    shape-rendering: crispEdges;
}

.ecg-line {
    fill: none;
    stroke: #000000;
    stroke-width: 1.5px;
    stroke-linejoin: round;
    stroke-linecap: round;
    shape-rendering: geometricPrecision;
}

.calibration-pulse {
    stroke: #000000;
    stroke-width: 1.5px;
    fill: none;
    shape-rendering: crispEdges;
}

/* Analysis Panel */
.analysis-panel {
    margin-top: 2rem;
    background: white;
    border: 2px solid #8B0000;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(139,0,0,0.1);
}

.analysis-panel.hidden {
    display: none;
}

.analysis-panel h3 {
    color: #8B0000;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.analysis-results {
    display: grid;
    gap: 1rem;
}

.analysis-item {
    padding: 0.8rem;
    background: #f9f9f9;
    border-left: 4px solid #ddd;
    border-radius: 4px;
}

.analysis-item.normal {
    border-left-color: #28a745;
}

.analysis-item.warning {
    border-left-color: #ffc107;
    background: #fff9e6;
}

.analysis-item.abnormal {
    border-left-color: #dc3545;
    background: #ffe6e6;
}

.analysis-item h4 {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    color: #333;
}

.analysis-item p {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Scrollbar Styling */
.parameter-panel::-webkit-scrollbar {
    width: 6px;
}

.parameter-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.parameter-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.parameter-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    
    .parameter-panel {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
}

/* Print Styles */
@media print {
    .app-header, .parameter-panel, .header-actions {
        display: none;
    }
    
    .ecg-canvas-container {
        padding: 0;
    }
    
    #ecg-canvas {
        box-shadow: none;
    }
}
