:root {
    --primary-color: #5C6BC0;   /* Indigo for main actions (e.g., Add Table) */
    --secondary-color: #66BB6A;  /* Light Green for foreign keys */
    --danger-color: #EF5350;    /* Red for destructive actions */
    --warning-color: #FFCA28;   /* Amber for warning/primary key highlights */
    --info-color: #42A5F5;      /* Custom: Blue for import/load */
    --success-color: #4CAF50;   /* Custom: Green for export/save */
    --reset-color: #B0BEC5;    /* Custom: Lighter Gray for reset */
    --dark-color: #263238;      /* Dark Blue Gray for text/footer */
    --light-color: #ECEFF1;     /* Light Blue Gray for subtle backgrounds */
    --gray-color: #78909C;      /* Blue Gray for general text/borders */
    --light-gray: #E0E0E0;      /* Very light gray for backgrounds */
    --border-radius: 4px;
    --box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 2px 6px 2px rgba(60,64,67,0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: var(--dark-color);
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    overflow: hidden;
}

header {
    background-color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--box-shadow);
    z-index: 10;
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn.small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.btn.secondary { /* Default secondary, used by internal components if not overridden */
    background-color: var(--light-gray);
    color: var(--gray-color);
}

.btn.tertiary {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* New/Modified Button Styles by Function */
.btn.reset-btn {
    background-color: var(--reset-color);
    color: var(--dark-color);
}

.btn.import-btn {
    background-color: var(--info-color); /* Blue */
    color: white;
}

.btn.export-btn {
    background-color: var(--success-color); /* Green */
    color: white;
}

.btn.danger {
    background-color: var(--danger-color);
    color: white;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.schema-panel {
    width: 250px;
    background-color: white;
    border-right: 1px solid var(--light-gray);
    overflow-y: auto;
    padding: 1rem;
}

.designer-area {
    flex: 1;
    background-color: #f9f9f9;
    overflow: auto;
    position: relative;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 500px;
    background-color: white;
    background-image: linear-gradient(#eee 1px, transparent 1px),
                      linear-gradient(90deg, #eee 1px, transparent 1px);
    background-size: 20px 20px;
}

.designer-canvas {
    position: absolute;
    width: 2000px;
    height: 2000px;
    transform-origin: 0 0;
}

.table-card {
    position: absolute;
    width: 220px;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    cursor: move;
    user-select: none;
    z-index: 10;
}

.table-header {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-icon {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.8rem;
}

.columns-list {
    padding: 0.5rem;
}

.column-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--light-gray);
}

.column-item:last-child {
    border-bottom: none;
}

.column-name {
    flex: 1;
}

.column-type {
    color: var(--gray-color);
    font-size: 0.7rem;
    font-family: monospace;
    margin: 0 0.5rem;
}

.column-icons {
    display: flex;
    gap: 0.25rem;
}

.column-icons i {
    font-size: 0.7rem;
}

.primary-key {
    color: var(--warning-color);
    display: none;
}

.foreign-key {
    color: var(--secondary-color);
    display: none;
}

.table-footer {
    padding: 0.5rem;
    background-color: var(--light-color);
    text-align: center;
}

.table-footer button {
    width: 100%;
    font-size: 0.7rem;
}

.properties-panel {
    width: 300px;
    background-color: white;
    border-left: 1px solid var(--light-gray);
    overflow-y: auto;
    padding: 1rem;
}

.properties-form {
    padding: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn.danger {
    background-color: var(--danger-color);
    color: white;
}

.relation-line {
    position: absolute;
    background-color: var(--secondary-color);
    height: 2px;
    transform-origin: 0 0;
    z-index: 5;
    pointer-events: none;
}

.relation-line::after {
    content: '';
    position: absolute;
    right: -5px;
    top: -4px;
    width: 0;
    height: 0;
    border-left: 6px solid var(--secondary-color);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

.linking-line {
    position: absolute;
    background-color: var(--primary-color); /* Use primary color for temporary line */
    height: 2px;
    transform-origin: 0 0;
    z-index: 100; /* Ensure it's on top */
    pointer-events: none; /* Do not block mouse events on elements below */
}

.linking-line::after {
    content: '';
    position: absolute;
    right: -5px;
    top: -4px;
    width: 0;
    height: 0;
    border-left: 6px solid var(--primary-color);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}


.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--gray-color);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.highlight {
    box-shadow: 0 0 0 2px var(--warning-color);
}

/* Footer Styles */
.app-footer {
    background-color: var(--dark-color);
    color: white;
    padding: 2rem 1rem;
    margin-top: auto;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 2rem;
}

.footer-section {
    flex: 1;
    min-width: 200px;
}

.footer-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.footer-section p, .footer-section li {
    color: #d1d1d1;
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: #d1d1d1;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8rem;
    color: #aaa;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .schema-panel, .properties-panel {
        width: 200px;
    }
}

@media (max-width: 992px) {
    .main-content {
        flex-direction: column;
    }
    .schema-panel, .properties-panel {
        width: 100%;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid var(--light-gray);
    }
    .designer-area {
        order: 1;
    }
}